diff --git a/default.nix b/default.nix index afed8b7c..626193ee 100644 --- a/default.nix +++ b/default.nix @@ -2,11 +2,10 @@ with lib; with lib.my; -with inputs; { imports = # I use home-manager to deploy files to $HOME; little else - [ home-manager.nixosModules.home-manager ] + [ inputs.home-manager.nixosModules.home-manager ] # All my personal modules ++ (mapModulesRec' (toString ./modules) import); @@ -16,26 +15,27 @@ with inputs; # Configure nix and nixpkgs environment.variables.NIXPKGS_ALLOW_UNFREE = "1"; - nix = { - package = pkgs.nixFlakes; - extraOptions = "experimental-features = nix-command flakes"; - nixPath = (mapAttrsToList (n: v: "${n}=${v}") inputs) ++ [ - "nixpkgs-overlays=${dotFilesDir}/overlays" - "dotfiles=${dotFilesDir}" - ]; - binaryCaches = [ - "https://nix-community.cachix.org" - ]; - binaryCachePublicKeys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - registry = { - nixos.flake = nixpkgs; - nixpkgs.flake = nixpkgs-unstable; + nix = + let filteredInputs = filterAttrs (n: _: n != "self") inputs; + nixPathInputs = mapAttrsToList (n: v: "${n}=${v}") filteredInputs; + registryInputs = mapAttrs (_: v: { flake = v; }) filteredInputs; + in { + package = pkgs.nixFlakes; + extraOptions = "experimental-features = nix-command flakes"; + nixPath = nixPathInputs ++ [ + "nixpkgs-overlays=${dotFilesDir}/overlays" + "dotfiles=${dotFilesDir}" + ]; + binaryCaches = [ + "https://nix-community.cachix.org" + ]; + binaryCachePublicKeys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + registry = registryInputs // { dotfiles.flake = inputs.self; }; + useSandbox = true; }; - useSandbox = true; - }; - system.configurationRevision = mkIf (self ? rev) self.rev; + system.configurationRevision = with inputs; mkIf (self ? rev) self.rev; system.stateVersion = "20.09"; diff --git a/flake.nix b/flake.nix index ac57b4bf..f4df07d2 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,7 @@ { dotfiles = import ./.; } // mapModulesRec ./modules import; nixosConfigurations = - mapHosts ./hosts { inherit system; }; + mapHosts ./hosts {}; devShell."${system}" = import ./shell.nix { inherit pkgs; }; diff --git a/lib/nixos.nix b/lib/nixos.nix index d0679717..4595af76 100644 --- a/lib/nixos.nix +++ b/lib/nixos.nix @@ -2,12 +2,12 @@ with lib; with lib.my; -let system = "x86_64-linux"; +let sys = "x86_64-linux"; in { - mkHost = path: attrs @ { system ? system, ... }: + mkHost = path: attrs @ { system ? sys, ... }: nixosSystem { inherit system; - specialArgs = { inherit lib inputs; }; + specialArgs = { inherit lib inputs system; }; modules = [ { nixpkgs.pkgs = pkgs; diff --git a/lib/paths.nix b/lib/paths.nix index dfe3b6a9..ace93620 100644 --- a/lib/paths.nix +++ b/lib/paths.nix @@ -9,7 +9,4 @@ rec { configDir = "${dotFilesDir}/config"; binDir = "${dotFilesDir}/bin"; themesDir = "${modulesDir}/themes"; - homeDir = "/home/${let name = getEnv "USERNAME"; in - if elem name [ "" "root" ] - then "hlissner" else name}"; } diff --git a/modules/desktop/browsers/firefox.nix b/modules/desktop/browsers/firefox.nix index 4deacc88..dbe4abac 100644 --- a/modules/desktop/browsers/firefox.nix +++ b/modules/desktop/browsers/firefox.nix @@ -47,7 +47,7 @@ in { # Enable userContent.css and userChrome.css for our theme modules "toolkit.legacyUserProfileCustomizations.stylesheets" = true; # Stop creating ~/Downloads! - "browser.download.dir" = "${homeDir}/dl"; + "browser.download.dir" = "${config.user.home}/dl"; # Don't use the built-in password manager; a nixos user is more likely # using an external one (you are using one, right?). "signon.rememberSignons" = false; diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index f2bf219f..ca8f035d 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -113,7 +113,7 @@ in { # Clean up leftovers, as much as we can system.userActivationScripts.cleanupHome = '' - pushd "${homeDir}" + pushd "${config.user.home}" rm -rf .compose-cache .nv .pki .dbus .fehbg [ -s .xsession-errors ] || rm -f .xsession-errors* popd diff --git a/modules/options.nix b/modules/options.nix index 9ada8288..f635130f 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -24,15 +24,17 @@ with lib.my; }; config = { - user = { - description = "The primary user account"; - extraGroups = [ "wheel" ]; - isNormalUser = true; - name = let name = builtins.getEnv "USER"; in - if elem name [ "" "root" ] - then "hlissner" else name; - uid = 1000; - }; + user = + let user = builtins.getEnv "USER"; + name = if elem user [ "" "root" ] then "hlissner" else user; + in { + inherit name; + description = "The primary user account"; + extraGroups = [ "wheel" ]; + isNormalUser = true; + home = "/home/${name}"; + uid = 1000; + }; # Install user packages to /etc/profiles instead. Necessary for # nixos-rebuild build-vm to work. diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix index 83724971..203c43e5 100644 --- a/modules/services/transmission.nix +++ b/modules/services/transmission.nix @@ -11,7 +11,7 @@ in { config = mkIf cfg.enable { services.transmission = { enable = true; - home = "${homeDir}/torrents"; + home = "${config.user.home}/torrents"; settings = { incomplete-dir-enabled = true; rpc-whitelist = "127.0.0.1,192.168.*.*";