diff --git a/flake.nix b/flake.nix index a4aa500..a5dea99 100644 --- a/flake.nix +++ b/flake.nix @@ -38,18 +38,29 @@ }; }; - outputs = inputs @ { self, nixpkgs, ... }: + outputs = inputs @ { self, nixpkgs, hardware, ... }: let system = "x86_64-linux"; in { - homeConfigurations = import ./outputs/home.nix { - inherit inputs system; - }; + nixosConfigurations = + nixpkgs.lib.mapAttrs + (hostname: { system + , specialArgs ? { } + , extraModules ? [ ] + , nixpkgs ? inputs.nixpkgs + }: + nixpkgs.lib.nixosSystem { + inherit system; - nixosConfigurations = import ./outputs/system.nix { - inherit inputs system; - }; + specialArgs = { inherit inputs; } // specialArgs; + + modules = + (with inputs; [ home-manager.nixosModule ]) + ++ [ ./machines/${hostname} ] + ++ extraModules; + }) + (import ./machines inputs); devShells.${system} = let diff --git a/system/machine/asus_gl553vd/default.nix b/machines/asus_gl553vd/default.nix similarity index 72% rename from system/machine/asus_gl553vd/default.nix rename to machines/asus_gl553vd/default.nix index 624004e..3acaa67 100644 --- a/system/machine/asus_gl553vd/default.nix +++ b/machines/asus_gl553vd/default.nix @@ -1,22 +1,22 @@ { config, pkgs, lib, ... }: let - secrets = import ../../../secrets.nix; + secrets = import ../../secrets.nix; in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ../common.nix ]; - # Use the systemd-boot EFI boot loader. - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; + # Use latest kernel + boot.kernelPackages = pkgs.linuxPackages_latest; - kernelPackages = pkgs.linuxPackages_latest; + # Use the systemd-boot EFI boot loader. + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; }; networking = { @@ -33,7 +33,7 @@ in hardware.bluetooth.enable = true; services.blueman.enable = true; - # configure touchpad + # configure mouse and touchpad services.xserver.libinput = { enable = true; mouse = { diff --git a/system/machine/asus_gl553vd/hardware-configuration.nix b/machines/asus_gl553vd/hardware-configuration.nix similarity index 100% rename from system/machine/asus_gl553vd/hardware-configuration.nix rename to machines/asus_gl553vd/hardware-configuration.nix diff --git a/system/configuration.nix b/machines/common.nix similarity index 90% rename from system/configuration.nix rename to machines/common.nix index d40e254..1e91785 100644 --- a/system/configuration.nix +++ b/machines/common.nix @@ -4,9 +4,6 @@ { config, pkgs, ... }: -let - secrets = import ../secrets.nix; -in { networking = { networkmanager.enable = true; @@ -56,9 +53,6 @@ in # Enable the X11 windowing system. services = { - # Enable the OpenSSH daemon. - openssh.enable = true; - # Xmonad dbus = { enable = true; @@ -95,17 +89,6 @@ in programs.zsh.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.me = { - isNormalUser = true; - name = secrets.mainUser.userName; - home = secrets.mainUser.userDir; - extraGroups = [ - "wheel" # Enable ‘sudo’ for the user. - "networkmanager" - "docker" - ]; - shell = pkgs.zsh; - }; # List packages installed in system profile. To search, run: # $ nix search wget @@ -115,6 +98,9 @@ in wget ]; + # Enable the OpenSSH daemon. + services.openssh.enable = true; + # Some programs need SUID wrappers, can be configured further or are # started in user sessions. # programs.mtr.enable = true; @@ -131,7 +117,7 @@ in settings = { auto-optimise-store = true; - trusted-users = [ "root" secrets.mainUser.userName ]; + trusted-users = [ "root" ]; experimental-features = [ "nix-command" "flakes" ]; diff --git a/machines/default.nix b/machines/default.nix new file mode 100644 index 0000000..a8f6499 --- /dev/null +++ b/machines/default.nix @@ -0,0 +1,30 @@ +{ dedsec-grub-theme, ... } @ inputs: + +let + hardware = inputs.hardware.nixosModules; +in +{ + home = { + system = "x86_64-linux"; + + extraModules = [ + dedsec-grub-theme.nixosModule + ../modules/garbage-collector.nix + ../users/jan + ]; + }; + + asus_gl553vd = { + system = "x86_64-linux"; + + specialArgs = { + fontSize = 6.0; + }; + + extraModules = [ + hardware.common-cpu-intel + ../users/jan + ]; + }; + +} diff --git a/system/machine/home/default.nix b/machines/home/default.nix similarity index 96% rename from system/machine/home/default.nix rename to machines/home/default.nix index 7c9edd8..95d38ca 100644 --- a/system/machine/home/default.nix +++ b/machines/home/default.nix @@ -1,12 +1,13 @@ { config, pkgs, lib, ... }: let - secrets = import ../../../secrets.nix; + secrets = import ../../secrets.nix; in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ../common.nix ]; boot = { diff --git a/system/machine/home/hardware-configuration.nix b/machines/home/hardware-configuration.nix similarity index 100% rename from system/machine/home/hardware-configuration.nix rename to machines/home/hardware-configuration.nix diff --git a/makefile b/makefile index 49ab12f..f2561c9 100644 --- a/makefile +++ b/makefile @@ -1,17 +1,10 @@ -switchHm = home-manager switch --flake switchSys = nixos-rebuild switch --flake -users-jan: fix-systemd - ${switchHm} .#users-jan - -users-laptop-jan: fix-systemd - ${switchHm} .#users-laptop-jan - sys-home: - sudo ${switchSys} .#system-home + sudo ${switchSys} .#home sys-asus-gl553vd: - sudo ${switchSys} .#system-asus-gl553vd + sudo ${switchSys} .#asus_gl553vd fix-systemd: systemctl --user reset-failed diff --git a/system/garbage-collector.nix b/modules/garbage-collector.nix similarity index 100% rename from system/garbage-collector.nix rename to modules/garbage-collector.nix diff --git a/outputs/home.nix b/outputs/home.nix deleted file mode 100644 index 087664a..0000000 --- a/outputs/home.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ inputs, system, ... }: - -with inputs; - -let - pkgs = import nixpkgs { - inherit system; - - overlays = [ - inputs.wired.overlays.default - inputs.myneovim.overlays.default - inputs.vnetod.overlay - inputs.nil.overlays.default - ]; - }; - - mkUsersJan = mods: home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = [ - inputs.wired.homeManagerModules.default - ../users/jan/home.nix - ] ++ mods; - }; -in -{ - users-jan = mkUsersJan [ ]; - users-laptop-jan = mkUsersJan [ - ({ config, ... }: { - progs.alacritty.fontSize = 6.0; - }) - ]; -} diff --git a/outputs/system.nix b/outputs/system.nix deleted file mode 100644 index fb74b6d..0000000 --- a/outputs/system.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ inputs, system, ... }: - -with inputs; -{ - system-home = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - dedsec-grub-theme.nixosModule - ../system/configuration.nix - ../system/garbage-collector.nix - ../system/machine/home - ]; - }; - system-asus-gl553vd = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - hardware.nixosModules.common-cpu-intel - ../system/configuration.nix - ../system/machine/asus_gl553vd - ]; - }; -} diff --git a/secrets.nix b/secrets.nix index e9525d2..43ba5e0 100644 Binary files a/secrets.nix and b/secrets.nix differ diff --git a/users/jan/default.nix b/users/jan/default.nix new file mode 100644 index 0000000..94e1523 --- /dev/null +++ b/users/jan/default.nix @@ -0,0 +1,42 @@ +{ config, pkgs, lib, inputs, fontSize ? null, ... }: + +let + secrets = import ./secrets.nix; +in +{ + nixpkgs.overlays = (import ../../overlays) ++ [ + inputs.wired.overlays.default + inputs.myneovim.overlays.default + inputs.vnetod.overlay + inputs.nil.overlays.default + ]; + + users.users.jan = { + isNormalUser = true; + name = secrets.userName; + home = secrets.userDir; + extraGroups = [ + "wheel" # Enable ‘sudo’ for the user. + "networkmanager" + "docker" + ]; + shell = pkgs.zsh; + }; + + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.jan = { lib, ... }: { + imports = [ + inputs.wired.homeManagerModules.default + ./home.nix + ]; + + progs.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize; + + home.stateVersion = config.system.stateVersion; + }; + }; + + nix.settings.trusted-users = lib.mkForce [ "root" secrets.userName ]; +} diff --git a/users/jan/home.nix b/users/jan/home.nix index d891101..44bb41d 100644 --- a/users/jan/home.nix +++ b/users/jan/home.nix @@ -6,8 +6,6 @@ in { imports = (import ./ui) ++ (import ./shell) ++ (import ./progs); - nixpkgs.overlays = import ../../overlays; - # Home Manager needs a bit of information about you and the # paths it should manage. home.username = secrets.userName; @@ -136,16 +134,4 @@ in enable = true; config = ./wired.ron; }; - - # This value determines the Home Manager release that your - # configuration is compatible with. This helps avoid breakage - # when a new Home Manager release introduces backwards - # incompatible changes. - # - # You can update Home Manager without changing this value. See - # the Home Manager release notes for a list of state version - # changes in each release. - home.stateVersion = "21.11"; - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; }