From 85f739958f820d596e730b54cf7215d340160888 Mon Sep 17 00:00:00 2001 From: foglar Date: Sat, 15 Mar 2025 07:30:02 +0100 Subject: [PATCH] package ve flake --- prezentace.md | 66 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/prezentace.md b/prezentace.md index 4dddfa7..09b8f5b 100644 --- a/prezentace.md +++ b/prezentace.md @@ -46,7 +46,7 @@ nix run nixpkgs#cowsay #New --- -# Commandy +# Příkazy | Command | Na | | -------------- | ---------------------------------- | @@ -183,12 +183,6 @@ nix flake show github:kamadorueda/alejandra --- -# Nová flake z full templatu - -* `nix flake init --template templates#full` - ---- - # Inputs * `nix flake metadata --json | jq` - zobrazí vstupy @@ -300,6 +294,58 @@ pkgs.mkShell { --- +# Jak zabalit aplikaci do flake? + +--- + +```nix + outputs = {self, ...} @ inputs: let + supportedSystems = ["aarch64-linux" "i686-linux" "x86_64-linux"]; + forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = + forAllSystems (system: import inputs.nixpkgs {inherit system;}); + in { + packages = forAllSystems (system: let + pkgs = nixpkgsFor.${system}; + in { + default = self.packages.${system}.nix-install; + + nix-install = pkgs.writeShellApplication { + name = "nix-install"; + runtimeInputs = with pkgs; [git busybox gum]; + text = '' + echo "This is shell aplication in flake" + ''; + }; + }); + + apps = forAllSystems (system: { + default = self.apps.${system}.nix-install; + + nix-install = { + type = "app"; + program = "${self.packages.${system}.nix-install}/bin/nix-install"; + }; + }); + }; +``` + +--- + +* spuštění aplika e pomocí `nix run` +* `https://github.com/nixFreak/testApp` +* `nix run github:nixFreak/testApp` +* nebo přidání do flake inputů + +```nix + environment.systemPackages = [ + inputs.install-script.packages.${system}.default + inputs.zen-browser.packages.${system}.default + ]; +``` + +--- + # Nix language * `nix-repl` nebo `nix-instantiate --eval foo.nix` @@ -500,8 +546,10 @@ print("Hello world!") --- -# [EWW Flake](https://github.com/elkowar/eww/blob/master/flake.nix) +* # [EWW Flake](https://github.com/elkowar/eww/blob/master/flake.nix) + +* # `nix flake init --template templates#full` --- -# **Používejte Nix** +# **Používejte Nix!**