diff --git a/flake.lock b/flake.lock index 5514a3b..acfbfa7 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,26 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1705806513, + "narHash": "sha256-FcOmNjhHFfPz2udZbRpZ1sfyhVMr+C2O8kOxPj+HDDk=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "f8e04fbcebcc24cebc91989981bd45f69b963ed7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1705641746, @@ -72,6 +92,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "nix-index-database": "nix-index-database", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "pkg-android-tools": "pkg-android-tools" diff --git a/flake.nix b/flake.nix index ab4764c..ca0b2d2 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,12 @@ # 33.0.3p2 as suggested by https://xdaforums.com/t/guide-january-3-2024-root-pixel-7-pro-unlock-bootloader-pass-safetynet-both-slots-bootable-more.4505353/ # android tools versions [ 34.0.0, 34.0.5 ) causes bootloops somehow and 34.0.5 isn't in nixpkgs yet pkg-android-tools.url = "github:NixOS/nixpkgs/55070e598e0e03d1d116c49b9eff322ef07c6ac6"; + + # provides an up-to-date database for comma + nix-index-database = { + url = "github:nix-community/nix-index-database"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, nixpkgs, nixpkgs-unstable, ... }@inputs: @@ -47,7 +53,19 @@ # This function produces a module that adds the home-manager module to the # system and configures the given module to the user's Home Manager # configuration - homeManagerInit = {system, username ? _username , module}: { config, lib, pkgs, ... }: { + homeManagerInit = {system, username ? _username , module ? _ : {}, rootModule ? (import ./home/root.nix), userModules ? { ${username} = [ module ] ; root = [ rootModule ]; }, stateVersion }: + { config, lib, pkgs, ... }: + let + mapUserModules = lib.attrsets.mapAttrs (user: modules: {...}: + { + imports = modules; + config = { + home = { inherit stateVersion; }; + }; + }); + users = mapUserModules userModules; + in + { imports = [ inputs.home-manager.nixosModules.home-manager ]; @@ -55,7 +73,7 @@ home-manager = { useGlobalPkgs = true; useUserPackages = true; - users.${username} = module; + inherit users; extraSpecialArgs = { inherit inputs outputs vars; extraPkgs = mkExtraPkgs system; @@ -65,14 +83,23 @@ # This function produces a nixosSystem which imports configuration.nix and # a Home Manager home.nix for the given user from ./hosts/${hostname}/ - mkSystem = {system, hostname, username ? _username}: + mkSystem = {system, hostname, username ? _username, stateVersion}: lib.nixosSystem { inherit system; modules = [ + ({pkgs, config, lib, ...}@args: + { + # Values for every single system that would not conceivably need + # to be made modular + system.stateVersion = stateVersion; + # not having the freedom to install unfree programs is unfree + nixpkgs.config.allowUnfree = true; + nix.settings.experimental-features = ["nix-command" "flakes" ]; + }) ./hosts/${hostname}/configuration.nix (homeManagerInit { module = import ./hosts/${hostname}/home.nix; - inherit username system; + inherit username system stateVersion; }) ]; specialArgs = { @@ -95,26 +122,10 @@ homeManagerModules = (import ./modules/home-manager) moduleInputs; nixosConfigurations = { - slab = lib.nixosSystem rec { + slab = mkSystem { system = "x86_64-linux"; - modules = [ - ./hosts/slab/configuration.nix - ./hosts/slab/nvidia-optimus.nix - ./system/remote.nix - ./system/plasma.nix - ./system/fragments/opengl.nix - ./system/gaming.nix - ./system/android.nix - # ./system/hyprland.nix - (homeManagerInit { - module = import ./hosts/slab/home.nix; - inherit system; - }) - ]; - specialArgs = { - inherit inputs outputs vars; - extraPkgs = mkExtraPkgs system; - }; + hostname = "slab"; + stateVersion = "23.11"; }; nullbox = lib.nixosSystem rec { system = "x86_64-linux"; @@ -127,6 +138,7 @@ (homeManagerInit { module = import ./hosts/nullbox/home.nix; inherit system; + stateVersion = "23.11"; }) ]; }; diff --git a/home/comma.nix b/home/comma.nix new file mode 100644 index 0000000..203f26a --- /dev/null +++ b/home/comma.nix @@ -0,0 +1,10 @@ +{ lib, pkgs, config, inputs, ... } @args: +{ + imports = [ + inputs.nix-index-database.hmModules.nix-index + ]; + + home.packages = with pkgs; [ + comma + ]; +} diff --git a/home/root.nix b/home/root.nix new file mode 100644 index 0000000..266a894 --- /dev/null +++ b/home/root.nix @@ -0,0 +1,6 @@ +{ config, lib, pkgs, ... }@args: +{ + imports = [ + ./comma.nix + ]; +} diff --git a/hosts/slab/configuration.nix b/hosts/slab/configuration.nix index 6548b65..c26dd38 100644 --- a/hosts/slab/configuration.nix +++ b/hosts/slab/configuration.nix @@ -16,6 +16,13 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + + ./nvidia-optimus.nix + ../../system/remote.nix + ../../system/plasma.nix + ../../system/fragments/opengl.nix + ../../system/gaming.nix + ../../system/android.nix ]; networking.hostName = "slab";