From c875dd77fe88e9ffc2d13dfd354f926da7d0a8de Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 14 Apr 2025 21:12:17 +0200 Subject: [PATCH] feat: add testing infrastructure --- flake.lock | 619 +++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 20 ++ tests/default.nix | 8 + tests/shift.nix | 15 ++ 4 files changed, 661 insertions(+), 1 deletion(-) create mode 100644 tests/default.nix create mode 100644 tests/shift.nix diff --git a/flake.lock b/flake.lock index d4b6d24..e28dfde 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,46 @@ { "nodes": { + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "crane": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixt", + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1676162383, + "narHash": "sha256-krUCKdz7ebHlFYm/A7IbKDnj2ZmMMm3yIEQcooqm7+E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6fb400ec631b22ccdbc7090b38207f7fb5cfb5f2", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "devshell": { "inputs": { "nixpkgs": [ @@ -20,7 +61,115 @@ "type": "github" } }, + "devshell_2": { + "inputs": { + "flake-utils": [ + "nixt", + "std", + "flake-utils" + ], + "nixpkgs": [ + "nixt", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1682700442, + "narHash": "sha256-qjaAAcCYgp1pBBG7mY9z95ODUBZMtUpf0Qp3Gt/Wha0=", + "owner": "numtide", + "repo": "devshell", + "rev": "fb6673fe9fe4409e3f43ca86968261e970918a83", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "haumea": "haumea", + "namaka": "namaka", + "nixlib": [ + "nixt", + "std", + "nixpkgs" + ], + "yants": [ + "nixt", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1684178600, + "narHash": "sha256-EtSQcCHRQUBBEj4vbYU0vgPUYiKP261ero5k1QfQ3Bc=", + "owner": "divnix", + "repo": "dmerge", + "rev": "ac9932f26325afac5baa59cf6478432d17762a4e", + "type": "github" + }, + "original": { + "owner": "divnix", + "ref": "0.2.0", + "repo": "dmerge", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs_2", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1677306201, + "narHash": "sha256-VZ9x7qdTosFvVsrpgFHrtYfT6PU3yMIs7NRYn9ELapI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "0923f0c162f65ae40261ec940406049726cfeab4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "flake": false, "locked": { "lastModified": 1696426674, @@ -54,6 +203,36 @@ "type": "github" } }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -75,6 +254,140 @@ "type": "github" } }, + "haumea": { + "inputs": { + "nixpkgs": [ + "nixt", + "std", + "dmerge", + "nixlib" + ] + }, + "locked": { + "lastModified": 1681176209, + "narHash": "sha256-bJLDun6esIyWtwRVXcsgzGbh4UKu8wJDrPgykqPyzmg=", + "owner": "nix-community", + "repo": "haumea", + "rev": "b915b66b27da3a595d77b139e945bb0a2fcac926", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "haumea", + "type": "github" + } + }, + "incl": { + "inputs": { + "nixlib": [ + "nixt", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669263024, + "narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=", + "owner": "divnix", + "repo": "incl", + "rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", + "type": "github" + } + }, + "n2c": { + "inputs": { + "flake-utils": [ + "nixt", + "std", + "flake-utils" + ], + "nixpkgs": [ + "nixt", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677330646, + "narHash": "sha256-hUYCwJneMjnxTvj30Fjow6UMJUITqHlpUGpXMPXUJsU=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "ebca8f58d450cae1a19c07701a5a8ae40afc9efc", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "namaka": { + "inputs": { + "haumea": [ + "nixt", + "std", + "dmerge", + "haumea" + ], + "nixpkgs": [ + "nixt", + "std", + "dmerge", + "nixlib" + ] + }, + "locked": { + "lastModified": 1683059428, + "narHash": "sha256-ZTMqleCWmuNWhZE375gtF1j1JRkaKEUFN1AM43e7h4Y=", + "owner": "nix-community", + "repo": "namaka", + "rev": "2deba2f416454aec770bc1cc7365e39c73e6b1d7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "v0.1.1", + "repo": "namaka", + "type": "github" + } + }, + "nixago": { + "inputs": { + "flake-utils": [ + "nixt", + "std", + "flake-utils" + ], + "nixago-exts": [ + "nixt", + "std", + "blank" + ], + "nixpkgs": [ + "nixt", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1683210100, + "narHash": "sha256-bhGDOlkWtlhVECpoOog4fWiFJmLCpVEg09a40aTjCbw=", + "owner": "nix-community", + "repo": "nixago", + "rev": "1da60ad9412135f9ed7a004669fdcf3d378ec630", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixago", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1737885589, @@ -103,9 +416,170 @@ "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" } }, - "pre-commit-hooks": { + "nixpkgs_2": { + "locked": { + "lastModified": 1677063315, + "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "988cc958c57ce4350ec248d2d53087777f9e1949", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixt": { "inputs": { "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "std": "std", + "std-data-collection": "std-data-collection" + }, + "locked": { + "lastModified": 1729273076, + "narHash": "sha256-h2Y+5bikSXS8MPYpxyZpd+VX9H5uuCS/csMMxZCoS3c=", + "owner": "nix-community", + "repo": "nixt", + "rev": "ad8863c9f9e5a166d663f2f1f0eef74ab913a883", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixt", + "type": "github" + } + }, + "nosys": { + "locked": { + "lastModified": 1668010795, + "narHash": "sha256-JBDVBnos8g0toU7EhIIqQ1If5m/nyBqtHhL3sicdPwI=", + "owner": "divnix", + "repo": "nosys", + "rev": "feade0141487801c71ff55623b421ed535dbdefa", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "nosys", + "type": "github" + } + }, + "paisano": { + "inputs": { + "nixpkgs": [ + "nixt", + "std", + "nixpkgs" + ], + "nosys": "nosys", + "yants": [ + "nixt", + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1678949904, + "narHash": "sha256-oAoF66hYYz1RPh3lEwb9/4e4iyBAfTbQKZRRQ8gP0Ds=", + "owner": "paisano-nix", + "repo": "core", + "rev": "88f2aff10a5064551d1d4cb86800d17084489ce3", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "core", + "type": "github" + } + }, + "paisano-actions": { + "inputs": { + "nixpkgs": [ + "nixt", + "std", + "paisano-mdbook-preprocessor", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677306424, + "narHash": "sha256-H9/dI2rGEbKo4KEisqbRPHFG2ajF8Tm111NPdKGIf28=", + "owner": "paisano-nix", + "repo": "actions", + "rev": "65ec4e080b3480167fc1a748c89a05901eea9a9b", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "actions", + "type": "github" + } + }, + "paisano-mdbook-preprocessor": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "nixpkgs": [ + "nixt", + "std", + "nixpkgs" + ], + "paisano-actions": "paisano-actions", + "std": [ + "nixt", + "std" + ] + }, + "locked": { + "lastModified": 1680654400, + "narHash": "sha256-Qdpio+ldhUK3zfl22Mhf8HUULdUOJXDWDdO7MIK69OU=", + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "rev": "11a8fc47f574f194a7ae7b8b98001f6143ba4cf1", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "repo": "mdbook-paisano-preprocessor", + "type": "github" + } + }, + "paisano-tui": { + "inputs": { + "nixpkgs": [ + "nixt", + "std", + "blank" + ], + "std": [ + "nixt", + "std" + ] + }, + "locked": { + "lastModified": 1681847764, + "narHash": "sha256-mdd7PJW1BZvxy0cIKsPfAO+ohVl/V7heE5ZTAHzTdv8=", + "owner": "paisano-nix", + "repo": "tui", + "rev": "3096bad91cae73ab8ab3367d31f8a143d248a244", + "type": "github" + }, + "original": { + "owner": "paisano-nix", + "ref": "0.1.1", + "repo": "tui", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_3", "gitignore": "gitignore", "nixpkgs": [ "nixpkgs" @@ -130,8 +604,151 @@ "devshell": "devshell", "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", + "nixt": "nixt", "pre-commit-hooks": "pre-commit-hooks" } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1677221702, + "narHash": "sha256-1M+58rC4eTCWNmmX0hQVZP20t3tfYNunl9D/PrGUyGE=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f5401f620699b26ed9d47a1d2e838143a18dbe3b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "nixt", + "std", + "paisano-mdbook-preprocessor", + "crane", + "flake-utils" + ], + "nixpkgs": [ + "nixt", + "std", + "paisano-mdbook-preprocessor", + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "std": { + "inputs": { + "arion": [ + "nixt", + "std", + "blank" + ], + "blank": "blank", + "devshell": "devshell_2", + "dmerge": "dmerge", + "flake-utils": "flake-utils", + "incl": "incl", + "makes": [ + "nixt", + "std", + "blank" + ], + "microvm": [ + "nixt", + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": [ + "nixt", + "nixpkgs" + ], + "paisano": "paisano", + "paisano-mdbook-preprocessor": "paisano-mdbook-preprocessor", + "paisano-tui": "paisano-tui", + "yants": "yants" + }, + "locked": { + "lastModified": 1684180498, + "narHash": "sha256-kA58ms4yunOVPhe3r7V0IIKeWUV+vl4r2GTcfFfYW5o=", + "owner": "divnix", + "repo": "std", + "rev": "45b431ae09df98e046bcc8271aa209bdfc87444d", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "std-data-collection": { + "inputs": { + "nixpkgs": [ + "nixt", + "nixpkgs" + ], + "std": [ + "nixt", + "std" + ] + }, + "locked": { + "lastModified": 1676163535, + "narHash": "sha256-xofkWLBqU4zj5vzJhWor2Z9CyPGKt7UGkTchsCT48Po=", + "owner": "divnix", + "repo": "std-data-collection", + "rev": "f713d81a6197e1b0854fb201cc7acde5ef9e93d4", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std-data-collection", + "type": "github" + } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "nixt", + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667096281, + "narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=", + "owner": "divnix", + "repo": "yants", + "rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index aa4acff..6d78bad 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,10 @@ url = "github:cachix/pre-commit-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixt = { + url = "github:nix-community/nixt"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -28,6 +32,18 @@ "x86_64-linux" "aarch64-linux" ]; + flake.__nixt = inputs.nixt.lib.grow { + blocks = import ./tests { + inherit (inputs) nixt; + pkgs = import inputs.nixpkgs { + system = "x86_64-linux"; + config.allowUnfree = true; + overlays = [ + self.overlays.default + ]; + }; + }; + }; flake.modules = { flake = { @@ -76,6 +92,10 @@ package = statix; help = "Lint nix code"; } + { + package = inputs.nixt.packages.${system}.default; + help = "Lint nix code"; + } { package = deadnix; help = "Find unused expressions in nix code"; diff --git a/tests/default.nix b/tests/default.nix new file mode 100644 index 0000000..03d273d --- /dev/null +++ b/tests/default.nix @@ -0,0 +1,8 @@ +{ + nixt, + pkgs, + ... +}: +[ + (import ./shift.nix { inherit pkgs nixt; }) +] diff --git a/tests/shift.nix b/tests/shift.nix new file mode 100644 index 0000000..60f9a7c --- /dev/null +++ b/tests/shift.nix @@ -0,0 +1,15 @@ +{ + nixt, + pkgs, + ... +}: +let + inherit (nixt.lib) block describe it; + inherit (pkgs.lib.bit) left; +in +block ./shift.nix [ + (describe "" [ + (it "Single left shift" (left 1 1 == 2)) + (it "Single left shift" (left 1 2 == 2)) + ]) +]