From 2f4fd48e460f0ed444194a1e3aed7033d74a3cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amy=20de=20Buitl=C3=A9ir?= Date: Mon, 13 Oct 2025 19:57:13 +0100 Subject: [PATCH] better flake style --- source/new-flake/bash-flake/flake-5.nix | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 source/new-flake/bash-flake/flake-5.nix diff --git a/source/new-flake/bash-flake/flake-5.nix b/source/new-flake/bash-flake/flake-5.nix new file mode 100644 index 0000000..9a74f07 --- /dev/null +++ b/source/new-flake/bash-flake/flake-5.nix @@ -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 +}