From 95e7d86cc7690fab3a8dd13b7575e6079d082b62 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 3 Aug 2022 01:51:15 -0700 Subject: [PATCH] packages: address a TODO by moving extra stuff into home-manager --- modules/universal/env/home-manager.nix | 18 ++++++++++++------ modules/universal/env/home-packages.nix | 7 +------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/universal/env/home-manager.nix b/modules/universal/env/home-manager.nix index 1c237ea30..d72ab32d4 100644 --- a/modules/universal/env/home-manager.nix +++ b/modules/universal/env/home-manager.nix @@ -10,6 +10,10 @@ with lib; let cfg = config.sane.home-manager; vim-swap-dir = ".cache/vim-swap"; + # extract package from `extraPackages` + pkglist = pkgspec: builtins.map (e: e.pkg or e) pkgspec; + # extract `dir` from `extraPackages` + dirlist = pkgspec: builtins.concatLists (builtins.map (e: if e ? "dir" then [ e.dir ] else []) pkgspec); in { options = { @@ -19,7 +23,9 @@ in }; sane.home-manager.extraPackages = mkOption { default = [ ]; - type = types.listOf types.package; + # each entry can be either a package, or attrs: + # { pkg = package; dir = optional string; + type = types.listOf (types.either types.package types.attrs); }; # attributes to copy directly to home-manager's `wayland.windowManager` option sane.home-manager.windowManager = mkOption { @@ -51,7 +57,7 @@ in "Pictures" "Videos" vim-swap-dir - ]; + ] ++ (dirlist cfg.extraPackages); home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; @@ -59,6 +65,10 @@ in # XXX this weird rename + closure is to get home-manager's `config.lib.file` to exist. # see: https://github.com/nix-community/home-manager/issues/589#issuecomment-950474105 home-manager.users.colin = let sysconfig = config; in { config, ... }: { + + home.packages = pkglist cfg.extraPackages; + wayland.windowManager = cfg.windowManager; + home.stateVersion = "21.11"; home.username = "colin"; home.homeDirectory = "/home/colin"; @@ -286,10 +296,6 @@ in "cd.." = "cd .."; "cd../" = "cd ../"; }; - - wayland.windowManager = cfg.windowManager; - - home.packages = cfg.extraPackages; }; }; } diff --git a/modules/universal/env/home-packages.nix b/modules/universal/env/home-packages.nix index 56ddf7d34..5f3448f27 100644 --- a/modules/universal/env/home-packages.nix +++ b/modules/universal/env/home-packages.nix @@ -104,9 +104,6 @@ let # zcash coins. safe to delete, just slow to regenerate (10-60 minutes) { pkg = zecwallet-lite; dir = ".zcash"; } ] else []); - - pkglist = builtins.map (e: e.pkg or e) pkgspec; - dirlist = builtins.concatLists (builtins.map (e: if e ? "dir" then [ e.dir ] else []) pkgspec); in { # useful devtools: @@ -120,7 +117,5 @@ in # mix2nix # rustup # swig - sane.home-manager.extraPackages = pkglist; - # TODO: this should be gated behind home-manager being enabled... - sane.impermanence.home-dirs = dirlist; + sane.home-manager.extraPackages = pkgspec; }