Add experimental NixOS module
This commit is contained in:
parent
5d64fec19a
commit
7265ef755a
|
@ -11,4 +11,6 @@ rec {
|
|||
"home-manager-install"
|
||||
{ propagatedBuildInputs = [ home-manager ]; }
|
||||
"";
|
||||
|
||||
nixos = import ./nixos;
|
||||
}
|
||||
|
|
|
@ -10,60 +10,6 @@ with lib;
|
|||
|
||||
let
|
||||
|
||||
modules = [
|
||||
./files.nix
|
||||
./home-environment.nix
|
||||
./manual.nix
|
||||
./misc/fontconfig.nix
|
||||
./misc/gtk.nix
|
||||
./misc/news.nix
|
||||
./misc/nixpkgs.nix
|
||||
./misc/pam.nix
|
||||
./programs/bash.nix
|
||||
./programs/beets.nix
|
||||
./programs/browserpass.nix
|
||||
./programs/command-not-found/command-not-found.nix
|
||||
./programs/eclipse.nix
|
||||
./programs/emacs.nix
|
||||
./programs/feh.nix
|
||||
./programs/firefox.nix
|
||||
./programs/git.nix
|
||||
./programs/gnome-terminal.nix
|
||||
./programs/home-manager.nix
|
||||
./programs/htop.nix
|
||||
./programs/info.nix
|
||||
./programs/lesspipe.nix
|
||||
./programs/man.nix
|
||||
./programs/rofi.nix
|
||||
./programs/ssh.nix
|
||||
./programs/termite.nix
|
||||
./programs/texlive.nix
|
||||
./programs/vim.nix
|
||||
./programs/zsh.nix
|
||||
./services/blueman-applet.nix
|
||||
./services/compton.nix
|
||||
./services/dunst.nix
|
||||
./services/gnome-keyring.nix
|
||||
./services/gpg-agent.nix
|
||||
./services/keepassx.nix
|
||||
./services/network-manager-applet.nix
|
||||
./services/owncloud-client.nix
|
||||
./services/polybar.nix
|
||||
./services/random-background.nix
|
||||
./services/redshift.nix
|
||||
./services/screen-locker.nix
|
||||
./services/syncthing.nix
|
||||
./services/taffybar.nix
|
||||
./services/tahoe-lafs.nix
|
||||
./services/udiskie.nix
|
||||
./services/xscreensaver.nix
|
||||
./systemd.nix
|
||||
./xresources.nix
|
||||
./xsession.nix
|
||||
<nixpkgs/nixos/modules/misc/assertions.nix>
|
||||
<nixpkgs/nixos/modules/misc/meta.nix>
|
||||
];
|
||||
|
||||
collectFailed = cfg:
|
||||
map (x: x.message) (filter (x: !x.assertion) cfg.assertions);
|
||||
|
||||
|
@ -73,15 +19,9 @@ let
|
|||
in
|
||||
fold f res res.config.warnings;
|
||||
|
||||
pkgsModule = {
|
||||
config._module.args.baseModules = modules;
|
||||
config._module.args.pkgs = lib.mkDefault pkgs;
|
||||
config._module.check = check;
|
||||
config.nixpkgs.system = mkDefault pkgs.system;
|
||||
};
|
||||
|
||||
rawModule = lib.evalModules {
|
||||
modules = [ configuration ] ++ modules ++ [ pkgsModule ];
|
||||
modules = [ configuration ]
|
||||
++ (import ./modules.nix { inherit check lib pkgs; });
|
||||
};
|
||||
|
||||
module = showWarnings (
|
||||
|
|
|
@ -234,9 +234,13 @@ in
|
|||
# script's "check" and the "write" phases.
|
||||
home.activation.writeBoundary = dagEntryAnywhere "";
|
||||
|
||||
home.activation.installPackages = dagEntryAfter ["writeBoundary"] ''
|
||||
$DRY_RUN_CMD nix-env -i ${cfg.path}
|
||||
'';
|
||||
# Install packages to the user environment. This is a no-op if
|
||||
# Home Manager is used as a NixOS module.
|
||||
home.activation.installPackages = dagEntryAfter ["writeBoundary"] (
|
||||
optionalString (!config.nixosSubmodule) ''
|
||||
$DRY_RUN_CMD nix-env -i ${cfg.path}
|
||||
''
|
||||
);
|
||||
|
||||
home.activationPackage =
|
||||
let
|
||||
|
|
85
modules/modules.nix
Normal file
85
modules/modules.nix
Normal file
|
@ -0,0 +1,85 @@
|
|||
{ pkgs
|
||||
, lib
|
||||
|
||||
# Whether to enable module type checking.
|
||||
, check ? true
|
||||
|
||||
# Whether these modules are inside a NixOS submodule.
|
||||
, nixosSubmodule ? false
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
modules = [
|
||||
./files.nix
|
||||
./home-environment.nix
|
||||
./manual.nix
|
||||
./misc/fontconfig.nix
|
||||
./misc/gtk.nix
|
||||
./misc/news.nix
|
||||
./misc/nixpkgs.nix
|
||||
./misc/pam.nix
|
||||
./programs/bash.nix
|
||||
./programs/beets.nix
|
||||
./programs/browserpass.nix
|
||||
./programs/command-not-found/command-not-found.nix
|
||||
./programs/eclipse.nix
|
||||
./programs/emacs.nix
|
||||
./programs/feh.nix
|
||||
./programs/firefox.nix
|
||||
./programs/git.nix
|
||||
./programs/gnome-terminal.nix
|
||||
./programs/home-manager.nix
|
||||
./programs/htop.nix
|
||||
./programs/info.nix
|
||||
./programs/lesspipe.nix
|
||||
./programs/man.nix
|
||||
./programs/rofi.nix
|
||||
./programs/ssh.nix
|
||||
./programs/termite.nix
|
||||
./programs/texlive.nix
|
||||
./programs/vim.nix
|
||||
./programs/zsh.nix
|
||||
./services/blueman-applet.nix
|
||||
./services/compton.nix
|
||||
./services/dunst.nix
|
||||
./services/gnome-keyring.nix
|
||||
./services/gpg-agent.nix
|
||||
./services/keepassx.nix
|
||||
./services/network-manager-applet.nix
|
||||
./services/owncloud-client.nix
|
||||
./services/polybar.nix
|
||||
./services/random-background.nix
|
||||
./services/redshift.nix
|
||||
./services/screen-locker.nix
|
||||
./services/syncthing.nix
|
||||
./services/taffybar.nix
|
||||
./services/tahoe-lafs.nix
|
||||
./services/udiskie.nix
|
||||
./services/xscreensaver.nix
|
||||
./systemd.nix
|
||||
./xresources.nix
|
||||
./xsession.nix
|
||||
<nixpkgs/nixos/modules/misc/assertions.nix>
|
||||
<nixpkgs/nixos/modules/misc/meta.nix>
|
||||
];
|
||||
|
||||
pkgsModule = {
|
||||
options.nixosSubmodule = mkOption {
|
||||
type = types.bool;
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
config._module.args.baseModules = modules;
|
||||
config._module.args.pkgs = lib.mkDefault pkgs;
|
||||
config._module.check = check;
|
||||
config.nixosSubmodule = nixosSubmodule;
|
||||
config.nixpkgs.system = mkDefault pkgs.system;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
map import modules ++ [ pkgsModule ]
|
|
@ -45,7 +45,7 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = mkIf (cfg.enable && !config.nixosSubmodule) {
|
||||
assertions = [{
|
||||
assertion = cfg.path == null || cfg.modulesPath == null;
|
||||
message = "Cannot simultaneously use "
|
||||
|
|
|
@ -117,7 +117,9 @@ in
|
|||
++
|
||||
(buildServices "timer" cfg.timers)
|
||||
);
|
||||
})
|
||||
|
||||
(mkIf (pkgs.stdenv.isLinux && !config.nixosSubmodule) {
|
||||
home.activation.reloadSystemD = dagEntryAfter ["linkGeneration"] ''
|
||||
function systemdPostReload() {
|
||||
local workDir
|
||||
|
|
42
nixos/default.nix
Normal file
42
nixos/default.nix
Normal file
|
@ -0,0 +1,42 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.home-manager;
|
||||
|
||||
hmModule = types.submodule (
|
||||
import ../modules/modules.nix {
|
||||
inherit lib pkgs;
|
||||
nixosSubmodule = true;
|
||||
}
|
||||
);
|
||||
|
||||
activateUser = username: usercfg: ''
|
||||
echo Activating home-manager configuration for ${username}
|
||||
${pkgs.sudo}/bin/sudo -u ${username} ${usercfg.home.activationPackage}/activate
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
home-manager.users = mkOption {
|
||||
type = types.attrsOf hmModule;
|
||||
default = {};
|
||||
description = ''
|
||||
Per-user Home Manager configuration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
system.activationScripts.home-manager =
|
||||
stringAfter [ "users" ] (
|
||||
concatStringsSep "\n" (
|
||||
mapAttrsToList activateUser cfg.users));
|
||||
|
||||
users.users = mapAttrs (n: v: { packages = v.home.packages; } ) cfg.users;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue