diff options
| author | Irene Knapp <ireneista@internetsafetylabs.org> | 2025-09-09 16:31:35 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@internetsafetylabs.org> | 2025-09-09 16:31:35 -0700 |
| commit | cd82f4a96839ad4b7907e0355a87ded23b5fe584 (patch) | |
| tree | a28a5de07c2dce0717e133cd45217b127e090aaa /flake.nix | |
| parent | 2d2f73a9257035398e90d32dcfb7db74313d8fe6 (diff) | |
add the mechanism by which Rust will ask the nix config for details
this also adds the beginnings of a test harness; the test harness will become useful in a future CL, but for now `nix flake check` should continue to do what we want it to, and maybe slightly more Change-Id: I7f05bcb5588f2b52d79cf05cf22263f084e8be49
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/flake.nix b/flake.nix index 9e73b80..8df1039 100644 --- a/flake.nix +++ b/flake.nix @@ -26,18 +26,18 @@ forAllSystems = nixpkgs.lib.genAttrs supportedSystems; nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); in { - packages = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { - default = (crane.mkLib pkgs).buildPackage { - src = ./.; - }; - }); - nixosModules.default = { ... }: { imports = [ ./options.nix ]; }; + packages = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { + default = (crane.mkLib pkgs).buildPackage { + src = ./.; + }; + }); + devShells = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ @@ -46,5 +46,45 @@ ]; }; }); + + checks = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + mkNixEvalCheck = name: input: expected: pkgs.stdenv.mkDerivation { + name = "smalltech-nix-test-${name}"; + + src = pkgs.symlinkJoin { + name = "smalltech-nix-test-${name}-src"; + paths = [ + (pkgs.writeTextDir "input" input) + (pkgs.writeTextDir "expected" "${expected}\n") + ]; + }; + + dontUnpack = true; + + nativeBuildInputs = with pkgs; [ diffutils nix ]; + + buildPhase = '' + mkdir nix-store + ${pkgs.nix}/bin/nix \ + --extra-experimental-features nix-command \ + --store dummy:// \ + eval --json --file $src/input > $out + + if ! ${pkgs.diffutils}/bin/diff $src/expected $out; then + echo + echo "This is a nix evaluation test case. The expected eval" + echo "output differed from the actual output. In an ideal" + echo "world, the above diff would help you understand why." + echo + false + fi + ''; + }; + in { + nix-trivial = mkNixEvalCheck "trivial" "1 + 2" "3"; + + rust = self.packages.${system}.default; + }); }; } |