diff options
-rw-r--r-- | flake.lock | 19 | ||||
-rw-r--r-- | flake.nix | 63 |
2 files changed, 63 insertions, 19 deletions
@@ -15,9 +15,26 @@ | |||
15 | "type": "github" | 15 | "type": "github" |
16 | } | 16 | } |
17 | }, | 17 | }, |
18 | "nixpkgs": { | ||
19 | "locked": { | ||
20 | "lastModified": 1636333654, | ||
21 | "narHash": "sha256-3wh9PtCzcaJQuZrgZ+ygKfhltkDNNqT6zOzGsRbjZEo=", | ||
22 | "owner": "NixOS", | ||
23 | "repo": "nixpkgs", | ||
24 | "rev": "e74894146a42ba552ebafa19ab2d1df7ccbc1738", | ||
25 | "type": "github" | ||
26 | }, | ||
27 | "original": { | ||
28 | "owner": "NixOS", | ||
29 | "ref": "nixos-21.05", | ||
30 | "repo": "nixpkgs", | ||
31 | "type": "github" | ||
32 | } | ||
33 | }, | ||
18 | "root": { | 34 | "root": { |
19 | "inputs": { | 35 | "inputs": { |
20 | "flake-utils": "flake-utils" | 36 | "flake-utils": "flake-utils", |
37 | "nixpkgs": "nixpkgs" | ||
21 | } | 38 | } |
22 | } | 39 | } |
23 | }, | 40 | }, |
@@ -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 | } |