From 57c60bcdcd5e25a59439a27b51eb369a0fa64118 Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Mon, 1 Feb 2021 20:57:14 -0700 Subject: [PATCH] suites: add users to suites --- DOC.md | 3 +++ hosts/NixOS.nix | 2 +- hosts/ci.nix | 2 +- profiles/suites.nix | 12 +++++++++--- users/nixos/default.nix | 1 + users/root/default.nix | 1 + 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/DOC.md b/DOC.md index 5a188459..d3838388 100644 --- a/DOC.md +++ b/DOC.md @@ -41,6 +41,9 @@ directly imported from any host like so: } ``` +You can declare any combination of users and profiles that you wish, providing +a nice abstraction, free from the idiosyncratic concerns of specific hardware. + ## Users User declarations belong in the `users` directory. diff --git a/hosts/NixOS.nix b/hosts/NixOS.nix index e7522f0e..6fd834ed 100644 --- a/hosts/NixOS.nix +++ b/hosts/NixOS.nix @@ -1,7 +1,7 @@ { suites, ... }: { ### root password is empty by default ### - imports = [ ../users/nixos ../users/root ] ++ suites.graphics; + imports = suites.graphics; boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; diff --git a/hosts/ci.nix b/hosts/ci.nix index 5a292960..90d28af0 100644 --- a/hosts/ci.nix +++ b/hosts/ci.nix @@ -1,6 +1,6 @@ { suites, ... }: { - imports = [ ../users/nixos ../users/root ] ++ suites.all; + imports = with suites; allProfiles ++ allUsers; security.mitigations.acceptRisk = true; diff --git a/profiles/suites.nix b/profiles/suites.nix index c8088388..99a901a0 100644 --- a/profiles/suites.nix +++ b/profiles/suites.nix @@ -1,16 +1,22 @@ { lib, profiles }: let inherit (builtins) mapAttrs isFunction; - all = + + allProfiles = let filtered = lib.filterAttrs (n: _: n != "core") profiles; in lib.collect isFunction filtered; + + allUsers = lib.collect isFunction users; + + users = lib.flk.defaultImports (toString ../users); in with profiles; mapAttrs (_: v: lib.flk.profileMap v) + # define your own suites below rec { - work = [ develop virt ]; + work = [ develop virt users.nixos users.root ]; graphics = work ++ [ graphical ]; @@ -24,5 +30,5 @@ mapAttrs (_: v: lib.flk.profileMap v) goPlay = play ++ [ laptop ]; } // { - inherit all; + inherit allProfiles allUsers; } diff --git a/users/nixos/default.nix b/users/nixos/default.nix index 409d9972..38bf20fd 100644 --- a/users/nixos/default.nix +++ b/users/nixos/default.nix @@ -1,3 +1,4 @@ +{ ... }: { home-manager.users.nixos = { imports = [ ../profiles/git ../profiles/direnv ]; diff --git a/users/root/default.nix b/users/root/default.nix index 9ca9d349..f38c7391 100644 --- a/users/root/default.nix +++ b/users/root/default.nix @@ -1,3 +1,4 @@ +{ ... }: # recommend using `hashedPassword` { users.users.root.password = "";