mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2025-12-26 16:24:56 +08:00
better flake style
This commit is contained in:
parent
e9565b0878
commit
2f4fd48e46
1 changed files with 59 additions and 0 deletions
59
source/new-flake/bash-flake/flake-5.nix
Normal file
59
source/new-flake/bash-flake/flake-5.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
description = "what does the cow say";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
|
||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
|
||||
forEachSystem = nixpkgs.lib.genAttrs supportedSystems;
|
||||
|
||||
nixpkgsFor = forEachSystem (system: import nixpkgs {
|
||||
inherit system;
|
||||
config = { };
|
||||
overlays = [ ];
|
||||
});
|
||||
|
||||
in {
|
||||
|
||||
devShells = forEachSystem (system:
|
||||
let pkgs = nixpkgsFor.${system}; in {
|
||||
default = pkgs.mkShell {
|
||||
packages = [ pkgs.cowsay ];
|
||||
};
|
||||
});
|
||||
|
||||
packages = forEachSystem (system:
|
||||
let pkgs = nixpkgsFor.${system}; in rec {
|
||||
hello = pkgs.stdenv.mkDerivation {
|
||||
name = "cow-hello.sh";
|
||||
src = ./.;
|
||||
unpackPhase = "true";
|
||||
buildPhase = ":";
|
||||
installPhase =
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
cp $src/cow-hello.sh $out/bin
|
||||
chmod +x $out/bin/cow-hello.sh
|
||||
'';
|
||||
buildInputs = [ pkgs.cowsay ];
|
||||
}; # mkDerivation
|
||||
|
||||
default = hello;
|
||||
}); # packages
|
||||
|
||||
apps = forEachSystem (system:
|
||||
let pkgs = nixpkgsFor.${system}; in rec {
|
||||
hello = {
|
||||
type = "app";
|
||||
program = pkgs.lib.getExe self.packages.${system}.hello;
|
||||
};
|
||||
|
||||
default = hello;
|
||||
});
|
||||
}; # outputs
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue