From 68f950bf2045573b03cd0e1ceebe7131ea999873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 4 Sep 2022 13:09:10 +0200 Subject: add test for standalone nixos config --- default.nix | 2 +- example/stand-alone/configuration.nix | 69 ++++++++++++++++++++++------------- tests/default.nix | 4 +- types.nix | 4 +- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/default.nix b/default.nix index 9febd80..4aa4ef5 100644 --- a/default.nix +++ b/default.nix @@ -2,7 +2,7 @@ , pkgs ? import {} }: let - types = import ./types.nix { inherit pkgs; }; + types = import ./types.nix { inherit lib pkgs; }; eval = cfg: lib.evalModules { modules = lib.singleton { # _file = toString input; diff --git a/example/stand-alone/configuration.nix b/example/stand-alone/configuration.nix index 2a15c32..600f6f9 100644 --- a/example/stand-alone/configuration.nix +++ b/example/stand-alone/configuration.nix @@ -1,39 +1,58 @@ -{ pkgs, lib, ... }: -let - disko = import (builtins.fetchGit { - url = "https://github.com/nix-community/disko"; - ref = "master"; - }) { +{ + pkgs, + lib, + ... +}: let + # We just import from the repository for testing here: + diskoNixos = import ../../. { inherit lib; }; + disko = import ../../. { + inherit lib; + inherit pkgs; + }; + # In your own system use something like this: + #import (builtins.fetchGit { + # url = "https://github.com/nix-community/disko"; + # ref = "master"; + #}) { + # inherit lib; + #}; cfg = { - type = "devices"; - content = { + disk = { sda = { - type = "table"; - format = "msdos"; - partitions = [{ - type = "partition"; - part-type = "primary"; - start = "1M"; - end = "100%"; - bootable = true; - content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; - }]; + device = "/dev/sda"; + type = "device"; + content = { + type = "table"; + format = "msdos"; + partitions = [ + { + name = "root"; + type = "partition"; + part-type = "primary"; + start = "1M"; + end = "100%"; + bootable = true; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + } + ]; + }; }; }; }; in { imports = [ - (disko.config cfg) + (diskoNixos.config cfg) ]; - environment.systemPackages = with pkgs;[ + boot.loader.grub.devices = [ "/dev/sda" ]; + system.stateVersion = "22.05"; + environment.systemPackages = with pkgs; [ (pkgs.writeScriptBin "tsp-create" (disko.create cfg)) (pkgs.writeScriptBin "tsp-mount" (disko.mount cfg)) ]; } - diff --git a/tests/default.nix b/tests/default.nix index 3118624..496a935 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -20,6 +20,8 @@ let ); allTests = lib.genAttrs (allTestFilenames) (test: import (./. + "/${test}.nix") { inherit makeDiskoTest; }) // - evalTest "lvm-luks-example" ../example/config.nix; + evalTest "lvm-luks-example" ../example/config.nix // { + standalone = (pkgs.nixos [ ../example/stand-alone/configuration.nix ]).config.system.build.toplevel; + }; in allTests diff --git a/types.nix b/types.nix index 81be650..c846626 100644 --- a/types.nix +++ b/types.nix @@ -1,5 +1,5 @@ -{ pkgs ? import {} }: -with pkgs.lib; +{ lib, pkgs }: +with lib; with builtins; rec { -- cgit v1.2.3