From b9835b5c6f1592f4ee7833586e3bdce1b0836af4 Mon Sep 17 00:00:00 2001 From: janabhumi Date: Sat, 8 Oct 2022 22:45:35 +0300 Subject: [PATCH] refac: use home as nixos module --- flake.nix | 25 ++++++++--- .../asus_gl553vd/default.nix | 18 ++++---- .../asus_gl553vd/hardware-configuration.nix | 0 .../configuration.nix => machines/common.nix | 22 ++------- machines/default.nix | 30 +++++++++++++ {system/machine => machines}/home/default.nix | 3 +- .../home/hardware-configuration.nix | 0 makefile | 11 +---- {system => modules}/garbage-collector.nix | 0 outputs/home.nix | 33 -------------- outputs/system.nix | 22 --------- secrets.nix | Bin 296 -> 176 bytes users/jan/default.nix | 42 ++++++++++++++++++ users/jan/home.nix | 14 ------ 14 files changed, 107 insertions(+), 113 deletions(-) rename {system/machine => machines}/asus_gl553vd/default.nix (72%) rename {system/machine => machines}/asus_gl553vd/hardware-configuration.nix (100%) rename system/configuration.nix => machines/common.nix (90%) create mode 100644 machines/default.nix rename {system/machine => machines}/home/default.nix (96%) rename {system/machine => machines}/home/hardware-configuration.nix (100%) rename {system => modules}/garbage-collector.nix (100%) delete mode 100644 outputs/home.nix delete mode 100644 outputs/system.nix create mode 100644 users/jan/default.nix 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 e9525d2ca4aad613681fce0fe569880032612990..43ba5e04ed18f4a789d03cd1c9167b88f3fcc0f4 100644 GIT binary patch literal 176 zcmV;h08jq_M@dveQdv+`0DSL1)=bp?@ZIpcuOy@95QdhiP+0<_dbJgA9b>`5tBJIM z?q@KdGiN}qSOOc<_WS`H_DEZ|rjA0yok~h^y4(}eu@9+o@kOO^z+1#Z{>mBLPfO7z z_+VkF=% zVEW^B8KyIJQuV=&UISZibqzf`Ch3&B+7W?v)f?I<5O-D3ete9#bTeyKd;igBbl#PJpG{JX;iYkGNm^&=D_ER3myvjBcrb( zqZhJbB&b_KDLb0#BDBjFrPvE{z%>s2Vdt6UWBm+cUfsfH$%H2*=|TI(`-