From 862e555516c75fe2556592430bf2b33d723b578b Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 5 Jun 2023 14:52:51 -0700 Subject: [PATCH] Turn nixos-shell vm into an integration test importing a module --- flake.lock | 21 +++++++++++++++++++++ flake.nix | 21 +++++++++++++++++++-- module.nix | 13 +++++++++++++ vm.nix => tests/demo.nix | 6 ++++-- 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 module.nix rename vm.nix => tests/demo.nix (95%) diff --git a/flake.lock b/flake.lock index b16eab7..c1aa7c6 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,26 @@ "type": "github" } }, + "nixos-shell": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1683035198, + "narHash": "sha256-5hHkokfSY3Z4VqjNm/j564l9Bgynw5H5McX0hTruGoI=", + "owner": "Mic92", + "repo": "nixos-shell", + "rev": "2cb76875e501eccb012625546864dd0085750843", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "nixos-shell", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1669833724, @@ -35,6 +55,7 @@ "root": { "inputs": { "flake-compat": "flake-compat", + "nixos-shell": "nixos-shell", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 4f8e2af..d950c17 100644 --- a/flake.nix +++ b/flake.nix @@ -3,14 +3,20 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/22.11"; + # Included to support default.nix and shell.nix flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; + # Included to support the integration test in tests/demo.nix + nixos-shell.url = "github:Mic92/nixos-shell"; + nixos-shell.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, flake-compat }: - let system = "x86_64-linux"; + outputs = { self, nixpkgs, flake-compat, nixos-shell }: + let + inherit (nixpkgs.lib) makeOverridable nixosSystem; + system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; in { packages.${system} = { @@ -38,5 +44,16 @@ path = builtins.path { path = ./template; name = "source"; }; description = "A basic intake source config"; }; + + nixosModules.intake = import ./module.nix self; + + nixosConfigurations."demo" = makeOverridable nixosSystem { + inherit system; + modules = [ + nixos-shell.nixosModules.nixos-shell + self.nixosModules.intake + ./tests/demo.nix + ]; + }; }; } diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..f38a820 --- /dev/null +++ b/module.nix @@ -0,0 +1,13 @@ +flake: { config, lib, pkgs, ... }: + +let + inherit (lib) mkIf mkOption types; + + cfg = config.services.intake; +in { + options = { + }; + + config = { + }; +} \ No newline at end of file diff --git a/vm.nix b/tests/demo.nix similarity index 95% rename from vm.nix rename to tests/demo.nix index 4bd072d..32447db 100644 --- a/vm.nix +++ b/tests/demo.nix @@ -1,5 +1,7 @@ -{ pkgs, ... }: { - boot.kernelPackages = pkgs.linuxPackages_latest; +{ pkgs, ... }: + +{ + system.stateVersion = "22.11"; nixos-shell.mounts = { mountHome = false;