diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 63 |
1 files changed, 45 insertions, 18 deletions
@@ -2,26 +2,53 @@ | |||
2 | description = "A simple bash library for your scripting needs"; | 2 | description = "A simple bash library for your scripting needs"; |
3 | 3 | ||
4 | inputs.flake-utils.url = "github:numtide/flake-utils"; | 4 | inputs.flake-utils.url = "github:numtide/flake-utils"; |
5 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05"; | ||
5 | 6 | ||
6 | outputs = { self, flake-utils }: | 7 | outputs = { self, flake-utils, nixpkgs, }: |
7 | with flake-utils.lib; | 8 | with flake-utils.lib; |
8 | eachSystem allSystems (system: { | 9 | (eachDefaultSystem (system: |
9 | 10 | let | |
10 | # Convert a path to a derivation | 11 | pkgs = import nixpkgs { |
11 | # This is done so we don't depend on nixpkgs | 12 | inherit system; |
12 | packages.bash-lib = with builtins; derivation { | 13 | overlays = [ self.overlay ]; |
13 | name = "bash-lib.sh"; | 14 | }; |
14 | src = readFile ./bash-lib.sh; | 15 | in |
15 | inherit system; | 16 | { |
16 | 17 | ||
17 | builder = "/bin/sh"; | 18 | packages.bash-lib = pkgs.bash-lib; |
18 | args = [ | 19 | |
19 | (toFile "builder.sh" '' | 20 | defaultPackage = self.packages.${system}.bash-lib; |
20 | echo "$src" > $out | 21 | |
21 | '') | 22 | })) // { |
22 | ]; | 23 | checks.x86_64-linux = { |
24 | runAndCheckDemo = | ||
25 | let | ||
26 | pkgs = import nixpkgs { | ||
27 | system = "x86_64-linux"; | ||
28 | overlays = [ self.overlay ]; | ||
29 | }; | ||
30 | in | ||
31 | pkgs.runCommand "runAndCheckDemo" { src = ./.; nativeBuildInputs = [ pkgs.shellcheck ]; } '' | ||
32 | unpackFile "$src" | ||
33 | cd */ | ||
34 | shellcheck ./bash-lib.sh | ||
35 | shellcheck -x ./demo.sh | ||
36 | |||
37 | chmod +w . demo.sh | ||
38 | sed '/^fatal/d' -i demo.sh | ||
39 | |||
40 | patchShebangs ./demo.sh | ||
41 | ./demo.sh | ||
42 | |||
43 | touch $out | ||
44 | ''; | ||
23 | }; | 45 | }; |
24 | 46 | ||
25 | defaultPackage = self.packages.${system}.bash-lib; | 47 | overlay = final: prev: { |
26 | }); | 48 | bash-lib = final.writeTextFile { |
49 | name = "bash-lib.sh"; | ||
50 | text = builtins.readFile ./bash-lib.sh; | ||
51 | }; | ||
52 | }; | ||
53 | }; | ||
27 | } | 54 | } |