incorporated john-p14s, big squash merge of stuff
This commit is contained in:
@@ -1,43 +1,91 @@
|
||||
{ inputs, ... }:
|
||||
{ self, inputs, ... }:
|
||||
{
|
||||
flake.modules.homeManager.rebuild =
|
||||
{ pkgs, lib, config, ... }:
|
||||
flake.modules.nixos.rebuild =
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
flakeDir = config.rebuild.flakeDir;
|
||||
echoCmd = lib.getExe' pkgs.coreutils "echo";
|
||||
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
|
||||
nfs = (pkgs.writeShellScriptBin "nfs" ''
|
||||
HOSTNAME=${hostnameCmd}
|
||||
${echoCmd} "Switching to the $HOSTNAME nixos profile"
|
||||
sudo ${lib.getExe pkgs.nixos-rebuild} switch --impure --flake ${flakeDir}#$HOSTNAME
|
||||
'');
|
||||
in
|
||||
{
|
||||
options = {
|
||||
homeManagerFlakeDir = lib.mkOption {
|
||||
options.rebuild = {
|
||||
flakeDir = lib.mkOption {
|
||||
description = "Path to the flake directory.";
|
||||
type = lib.types.str;
|
||||
default = "${config.xdg.configHome}/home-manager";
|
||||
description = "Path to the home-manager flake directory.";
|
||||
default = "/etc/nixos";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
nixBin = lib.getExe pkgs.nix;
|
||||
flakeDir = config.homeManagerFlakeDir;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
environment.systemPackages = with pkgs; [
|
||||
nfs
|
||||
(writeShellScriptBin "nfsu" ''
|
||||
${lib.getExe nix} flake update --impure --flake ${flakeDir}
|
||||
${lib.getExe git} -C ${flakeDir} add ${flakeDir}/flake.lock > /dev/null 2>&1
|
||||
${lib.getExe nfs}
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
flake.modules.homeManager.rebuild =
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
nixBin = lib.getExe pkgs.nix;
|
||||
flakeDir = config.homeManagerFlakeDir;
|
||||
echoCmd = lib.getExe' pkgs.coreutils "echo";
|
||||
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
|
||||
nhms = (pkgs.writeShellScriptBin "nhms" ''
|
||||
HOSTNAME=${hostnameCmd}
|
||||
${echoCmd} "Switching to the $HOSTNAME home-manager profile"
|
||||
${lib.getExe pkgs.home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
|
||||
'');
|
||||
in
|
||||
{
|
||||
options = {
|
||||
homeManagerFlakeDir = lib.mkOption {
|
||||
description = "Path to the home-manager flake directory.";
|
||||
type = lib.types.str;
|
||||
default = "${config.xdg.configHome}/home-manager";
|
||||
};
|
||||
buildHostname = lib.mkOption {
|
||||
description = "Hostname for the NixOS configuration to use.";
|
||||
type = lib.types.str;
|
||||
default = hostnameCmd;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
home.activation.printFlakeDir = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||
run echo "Home Manager flake directory: ${flakeDir}"
|
||||
run ${echoCmd} "Home Manager flake directory: ${flakeDir}"
|
||||
'';
|
||||
|
||||
home.packages = with pkgs; [
|
||||
home-manager
|
||||
(writeShellScriptBin "flake-parts-test" ''
|
||||
echo "Test ${flakeDir}"
|
||||
'')
|
||||
(writeShellScriptBin "flake-parts-check" ''
|
||||
cd ${flakeDir}
|
||||
${nixBin} run ".#write-flake"
|
||||
${nixBin} run "${flakeDir}#write-flake"
|
||||
${nixBin} flake check
|
||||
'')
|
||||
(writeShellScriptBin "nhms" ''
|
||||
HOSTNAME=$(hostname -s)
|
||||
echo "Switching to the $HOSTNAME profile"
|
||||
${lib.getExe home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
|
||||
'')
|
||||
nhms
|
||||
(writeShellScriptBin "nhmu" ''
|
||||
${nixBin} flake update --flake ${flakeDir}
|
||||
nhms
|
||||
${lib.getExe nhms}
|
||||
'')
|
||||
|
||||
(writeShellScriptBin "test-build" ''
|
||||
if [ -z "$1" ]; then
|
||||
HOSTNAME=${hostnameCmd}
|
||||
else
|
||||
HOSTNAME="$1"
|
||||
fi
|
||||
${echoCmd} "Testing the evaulation of the nixos config for $HOSTNAME"
|
||||
${lib.getExe nix} eval ${flakeDir}#nixosConfigurations.$HOSTNAME.config.system.build.toplevel.drvPath
|
||||
'')
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
# Lifted from:
|
||||
# https://github.com/Doc-Steve/dendritic-design-with-flake-parts/blob/69edacdb5a4a6ca71d649bb8eb62cf8c630c8627/modules/users/bob%20%5BNDn%5D/bob.nix#L8
|
||||
{ self, ... }:
|
||||
{ self, inputs, ... }:
|
||||
{
|
||||
config.flake.factory.user = username: isAdmin: {
|
||||
nixos."${username}" = { lib, pkgs, ... }: {
|
||||
config.flake.factory.user = {
|
||||
username,
|
||||
isAdmin ? false,
|
||||
noPassword ? false,
|
||||
# homeImports ? [ ],
|
||||
# homePackages ? [ ],
|
||||
}: {
|
||||
nixos."${username}" = { config, lib, pkgs, ... }: {
|
||||
imports = [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
];
|
||||
|
||||
users.users."${username}" = {
|
||||
isNormalUser = true;
|
||||
home = "/home/${username}";
|
||||
shell = lib.mkIf config.programs.zsh.enable pkgs.zsh;
|
||||
extraGroups = [
|
||||
"input"
|
||||
"networkmanager"
|
||||
@@ -21,7 +32,7 @@
|
||||
enable = true;
|
||||
extraRules = [{
|
||||
users = [ "${username}" ];
|
||||
commands = [{
|
||||
commands = lib.mkIf noPassword [{
|
||||
command = "ALL";
|
||||
options = [ "NOPASSWD" ];
|
||||
}];
|
||||
@@ -30,11 +41,10 @@
|
||||
|
||||
# https://github.com/Doc-Steve/dendritic-design-with-flake-parts/wiki/Dendritic_Aspects#multi-context-aspect
|
||||
home-manager.users."${username}" = {
|
||||
imports = [ self.modules.homeManager."${username}" ];
|
||||
home.username = "${username}";
|
||||
home.homeDirectory = "/home/${username}";
|
||||
imports = [
|
||||
self.modules.homeManager."${username}"
|
||||
];
|
||||
# home.packages = homePackages;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user