diff --git a/README.md b/README.md index 573b8ec..812294d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ # nixos-config [![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org) -This repository holds my NixOS configuration. It is fully reproducible, flakes -based, and position-independent, meaning there is no moving around of -`configuration.nix`. +This repository holds my NixOS configuration. +It is fully reproducible, flakes based, and position-independent, meaning there is no moving around of `configuration.nix`. Deployment is done using [deploy-rs](https://github.com/serokell/deploy-rs), see [usage](#usage). -Secret are managed using [sops-nix](https://github.com/Mic92/sops-nix). For formatting [pre-commit-hooks](https://github.com/cachix/pre-commit-hooks.nix) is used. +Secret are managed using [sops-nix](https://github.com/Mic92/sops-nix). +For formatting [pre-commit-hooks](https://github.com/cachix/pre-commit-hooks.nix) is used. ## structure ``` . -├── modules # Own nix-options, to modularize services -├── nixos # Machine definitions -└── pgks # Own packages, which are not available in nixpkgs +├── modules # Own nix-options, to modularize services/hardware/... +├── machines # Machine definitions +└── pkgs # Own packages, which are not available in nixpkgs ``` ## usage @@ -30,7 +30,7 @@ deploy .#myHost secrets: ```bash -sops ./nixos/myHost/secrets.yaml +sops ./machines/myHost/secrets.yaml ``` ## inspired by @@ -40,4 +40,4 @@ sops ./nixos/myHost/secrets.yaml - [Nix config by pborzenkov](https://github.com/pborzenkov/nix-config) - [Nix config by nyanloutre](https://gitea.nyanlout.re/nyanloutre/nixos-config) - [deploy-rs by disassembler](https://samleathers.com/posts/2022-02-03-my-new-network-and-deploy-rs.html) -- [pre-commit config](https://github.com/cachix/pre-commit-hooks.nix/blob/master/template/flake.nix) \ No newline at end of file +- [pre-commit config](https://github.com/cachix/pre-commit-hooks.nix/blob/master/template/flake.nix) diff --git a/flake.nix b/flake.nix index 64ecc24..baef79a 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,7 @@ flake-parts.lib.mkFlake { inherit self; } { imports = [ - ./nixos/configurations.nix + ./machines/configurations.nix #./nixos/images/default.nix inputs.pre-commit-hooks-nix.flakeModule ]; @@ -75,7 +75,7 @@ flake = { checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; - deploy = import ./nixos/deploy.nix (inputs // { + deploy = import ./machines/deploy.nix (inputs // { inherit inputs; }); }; diff --git a/nixos/modules/3d-design.nix b/legacy/modules/3d-design.nix similarity index 100% rename from nixos/modules/3d-design.nix rename to legacy/modules/3d-design.nix diff --git a/nixos/modules/3d-printer.nix b/legacy/modules/3d-printer.nix similarity index 100% rename from nixos/modules/3d-printer.nix rename to legacy/modules/3d-printer.nix diff --git a/nixos/modules/android.nix b/legacy/modules/android.nix similarity index 100% rename from nixos/modules/android.nix rename to legacy/modules/android.nix diff --git a/nixos/modules/avahi.nix b/legacy/modules/avahi.nix similarity index 100% rename from nixos/modules/avahi.nix rename to legacy/modules/avahi.nix diff --git a/nixos/modules/bluetooth-audio.nix b/legacy/modules/bluetooth-audio.nix similarity index 100% rename from nixos/modules/bluetooth-audio.nix rename to legacy/modules/bluetooth-audio.nix diff --git a/nixos/modules/clean.nix b/legacy/modules/clean.nix similarity index 100% rename from nixos/modules/clean.nix rename to legacy/modules/clean.nix diff --git a/nixos/modules/desktop-default.nix b/legacy/modules/desktop-default.nix similarity index 100% rename from nixos/modules/desktop-default.nix rename to legacy/modules/desktop-default.nix diff --git a/nixos/modules/desktop-development.nix b/legacy/modules/desktop-development.nix similarity index 100% rename from nixos/modules/desktop-development.nix rename to legacy/modules/desktop-development.nix diff --git a/nixos/modules/development.nix b/legacy/modules/development.nix similarity index 100% rename from nixos/modules/development.nix rename to legacy/modules/development.nix diff --git a/nixos/modules/docker.nix b/legacy/modules/docker.nix similarity index 100% rename from nixos/modules/docker.nix rename to legacy/modules/docker.nix diff --git a/nixos/modules/filesystem.nix b/legacy/modules/filesystem.nix similarity index 100% rename from nixos/modules/filesystem.nix rename to legacy/modules/filesystem.nix diff --git a/nixos/modules/fonts.nix b/legacy/modules/fonts.nix similarity index 100% rename from nixos/modules/fonts.nix rename to legacy/modules/fonts.nix diff --git a/nixos/modules/gaming.nix b/legacy/modules/gaming.nix similarity index 100% rename from nixos/modules/gaming.nix rename to legacy/modules/gaming.nix diff --git a/nixos/modules/hardware-base.nix b/legacy/modules/hardware-base.nix similarity index 100% rename from nixos/modules/hardware-base.nix rename to legacy/modules/hardware-base.nix diff --git a/nixos/modules/intel-video.nix b/legacy/modules/intel-video.nix similarity index 100% rename from nixos/modules/intel-video.nix rename to legacy/modules/intel-video.nix diff --git a/nixos/modules/intel.nix b/legacy/modules/intel.nix similarity index 100% rename from nixos/modules/intel.nix rename to legacy/modules/intel.nix diff --git a/nixos/modules/kvm.nix b/legacy/modules/kvm.nix similarity index 100% rename from nixos/modules/kvm.nix rename to legacy/modules/kvm.nix diff --git a/nixos/modules/location.nix b/legacy/modules/location.nix similarity index 100% rename from nixos/modules/location.nix rename to legacy/modules/location.nix diff --git a/nixos/modules/media.nix b/legacy/modules/media.nix similarity index 100% rename from nixos/modules/media.nix rename to legacy/modules/media.nix diff --git a/nixos/modules/meeting.nix b/legacy/modules/meeting.nix similarity index 100% rename from nixos/modules/meeting.nix rename to legacy/modules/meeting.nix diff --git a/nixos/modules/nautilus.nix b/legacy/modules/nautilus.nix similarity index 100% rename from nixos/modules/nautilus.nix rename to legacy/modules/nautilus.nix diff --git a/nixos/modules/networkdecrypt.nix b/legacy/modules/networkdecrypt.nix similarity index 100% rename from nixos/modules/networkdecrypt.nix rename to legacy/modules/networkdecrypt.nix diff --git a/nixos/modules/nix.nix b/legacy/modules/nix.nix similarity index 100% rename from nixos/modules/nix.nix rename to legacy/modules/nix.nix diff --git a/nixos/modules/power.nix b/legacy/modules/power.nix similarity index 100% rename from nixos/modules/power.nix rename to legacy/modules/power.nix diff --git a/nixos/modules/presentation.nix b/legacy/modules/presentation.nix similarity index 100% rename from nixos/modules/presentation.nix rename to legacy/modules/presentation.nix diff --git a/nixos/modules/printer.nix b/legacy/modules/printer.nix similarity index 100% rename from nixos/modules/printer.nix rename to legacy/modules/printer.nix diff --git a/nixos/modules/screen-sharing.nix b/legacy/modules/screen-sharing.nix similarity index 100% rename from nixos/modules/screen-sharing.nix rename to legacy/modules/screen-sharing.nix diff --git a/nixos/modules/security.nix b/legacy/modules/security.nix similarity index 100% rename from nixos/modules/security.nix rename to legacy/modules/security.nix diff --git a/nixos/modules/sway.nix b/legacy/modules/sway.nix similarity index 100% rename from nixos/modules/sway.nix rename to legacy/modules/sway.nix diff --git a/nixos/modules/sync.nix b/legacy/modules/sync.nix similarity index 100% rename from nixos/modules/sync.nix rename to legacy/modules/sync.nix diff --git a/nixos/modules/systemd-user.nix b/legacy/modules/systemd-user.nix similarity index 100% rename from nixos/modules/systemd-user.nix rename to legacy/modules/systemd-user.nix diff --git a/nixos/modules/systemduefi.nix b/legacy/modules/systemduefi.nix similarity index 100% rename from nixos/modules/systemduefi.nix rename to legacy/modules/systemduefi.nix diff --git a/nixos/modules/tex.nix b/legacy/modules/tex.nix similarity index 100% rename from nixos/modules/tex.nix rename to legacy/modules/tex.nix diff --git a/nixos/modules/theme.nix b/legacy/modules/theme.nix similarity index 100% rename from nixos/modules/theme.nix rename to legacy/modules/theme.nix diff --git a/nixos/modules/thunderbolt.nix b/legacy/modules/thunderbolt.nix similarity index 100% rename from nixos/modules/thunderbolt.nix rename to legacy/modules/thunderbolt.nix diff --git a/nixos/modules/webapps/bazarr.nix b/legacy/modules/webapps/bazarr.nix similarity index 100% rename from nixos/modules/webapps/bazarr.nix rename to legacy/modules/webapps/bazarr.nix diff --git a/nixos/modules/webapps/prowlarr.nix b/legacy/modules/webapps/prowlarr.nix similarity index 100% rename from nixos/modules/webapps/prowlarr.nix rename to legacy/modules/webapps/prowlarr.nix diff --git a/nixos/modules/webapps/radarr.nix b/legacy/modules/webapps/radarr.nix similarity index 100% rename from nixos/modules/webapps/radarr.nix rename to legacy/modules/webapps/radarr.nix diff --git a/nixos/modules/webapps/sonarr.nix b/legacy/modules/webapps/sonarr.nix similarity index 100% rename from nixos/modules/webapps/sonarr.nix rename to legacy/modules/webapps/sonarr.nix diff --git a/nixos/modules/webcam.nix b/legacy/modules/webcam.nix similarity index 100% rename from nixos/modules/webcam.nix rename to legacy/modules/webcam.nix diff --git a/nixos/.sops.yaml b/machines/.sops.yaml similarity index 100% rename from nixos/.sops.yaml rename to machines/.sops.yaml diff --git a/nixos/configurations.nix b/machines/configurations.nix similarity index 97% rename from nixos/configurations.nix rename to machines/configurations.nix index 9812089..f99609d 100644 --- a/nixos/configurations.nix +++ b/machines/configurations.nix @@ -16,7 +16,7 @@ let }; }; - customModules = import ./modules/default.nix; + customModules = import ./core/default.nix; baseModules = [ # make flake inputs accessiable in NixOS { diff --git a/nixos/modules/core.nix b/machines/core/core.nix similarity index 100% rename from nixos/modules/core.nix rename to machines/core/core.nix diff --git a/nixos/modules/default.nix b/machines/core/default.nix similarity index 100% rename from nixos/modules/default.nix rename to machines/core/default.nix diff --git a/nixos/modules/modules.nix b/machines/core/modules.nix similarity index 100% rename from nixos/modules/modules.nix rename to machines/core/modules.nix diff --git a/nixos/modules/network.nix b/machines/core/network.nix similarity index 100% rename from nixos/modules/network.nix rename to machines/core/network.nix diff --git a/nixos/modules/users.nix b/machines/core/users.nix similarity index 88% rename from nixos/modules/users.nix rename to machines/core/users.nix index 119457f..52a7730 100644 --- a/nixos/modules/users.nix +++ b/machines/core/users.nix @@ -1,6 +1,5 @@ { config, pkgs, lib, ... }: { - #sops.defaultSopsFile = ../secrets + "/${config.networking.hostName}/secrets.yaml"; sops.secrets."users/felix/password".neededForUsers = true; sops.secrets."users/felix/password" = { }; diff --git a/nixos/deploy.nix b/machines/deploy.nix similarity index 100% rename from nixos/deploy.nix rename to machines/deploy.nix diff --git a/nixos/newton/boot.nix b/machines/newton/boot.nix similarity index 100% rename from nixos/newton/boot.nix rename to machines/newton/boot.nix diff --git a/nixos/newton/configuration.nix b/machines/newton/configuration.nix similarity index 71% rename from nixos/newton/configuration.nix rename to machines/newton/configuration.nix index 5f2b5b6..e18bd3a 100644 --- a/nixos/newton/configuration.nix +++ b/machines/newton/configuration.nix @@ -7,12 +7,10 @@ ./network.nix ./syncthing.nix ./services.nix - #../modules/backup.nix - ../modules/docker.nix - ../modules/networkdecrypt.nix - ../modules/nix.nix - ../modules/users.nix - #../modules/webapps/radicale.nix + ../../legacy/modules/docker.nix + ../../legacy/modules/networkdecrypt.nix + ../../legacy/modules/nix.nix + ../../legacy/modules/users.nix ]; networking.hostName = "newton"; diff --git a/nixos/newton/disks.nix b/machines/newton/disks.nix similarity index 100% rename from nixos/newton/disks.nix rename to machines/newton/disks.nix diff --git a/nixos/newton/hardware-configuration.nix b/machines/newton/hardware-configuration.nix similarity index 100% rename from nixos/newton/hardware-configuration.nix rename to machines/newton/hardware-configuration.nix diff --git a/nixos/newton/network.nix b/machines/newton/network.nix similarity index 100% rename from nixos/newton/network.nix rename to machines/newton/network.nix diff --git a/nixos/newton/secrets.yaml b/machines/newton/secrets.yaml similarity index 100% rename from nixos/newton/secrets.yaml rename to machines/newton/secrets.yaml diff --git a/nixos/newton/services.nix b/machines/newton/services.nix similarity index 100% rename from nixos/newton/services.nix rename to machines/newton/services.nix diff --git a/nixos/newton/syncthing.nix b/machines/newton/syncthing.nix similarity index 100% rename from nixos/newton/syncthing.nix rename to machines/newton/syncthing.nix diff --git a/nixos/serverle/configuration.nix b/machines/serverle/configuration.nix similarity index 64% rename from nixos/serverle/configuration.nix rename to machines/serverle/configuration.nix index 2c3baf7..f7e965f 100644 --- a/nixos/serverle/configuration.nix +++ b/machines/serverle/configuration.nix @@ -7,14 +7,14 @@ ./services.nix ./syncthing.nix ./wifi.nix - #../modules/3d-printer.nix - ../modules/avahi.nix - ../modules/docker.nix - ../modules/nix.nix - ../modules/webapps/bazarr.nix - ../modules/webapps/prowlarr.nix - ../modules/webapps/radarr.nix - ../modules/webapps/sonarr.nix + #../../legacy/modules/3d-printer.nix + ../../legacy/modules/avahi.nix + ../../legacy/modules/docker.nix + ../../legacy/modules/nix.nix + ../../legacy/modules/webapps/bazarr.nix + ../../legacy/modules/webapps/prowlarr.nix + ../../legacy/modules/webapps/radarr.nix + ../../legacy/modules/webapps/sonarr.nix ]; networking.hostName = "serverle"; diff --git a/nixos/serverle/disks.nix b/machines/serverle/disks.nix similarity index 100% rename from nixos/serverle/disks.nix rename to machines/serverle/disks.nix diff --git a/nixos/serverle/dyndns.nix b/machines/serverle/dyndns.nix similarity index 100% rename from nixos/serverle/dyndns.nix rename to machines/serverle/dyndns.nix diff --git a/nixos/serverle/hardware-configuration.nix b/machines/serverle/hardware-configuration.nix similarity index 100% rename from nixos/serverle/hardware-configuration.nix rename to machines/serverle/hardware-configuration.nix diff --git a/nixos/serverle/secrets.yaml b/machines/serverle/secrets.yaml similarity index 100% rename from nixos/serverle/secrets.yaml rename to machines/serverle/secrets.yaml diff --git a/nixos/serverle/services.nix b/machines/serverle/services.nix similarity index 100% rename from nixos/serverle/services.nix rename to machines/serverle/services.nix diff --git a/nixos/serverle/syncthing.nix b/machines/serverle/syncthing.nix similarity index 100% rename from nixos/serverle/syncthing.nix rename to machines/serverle/syncthing.nix diff --git a/nixos/serverle/wifi.nix b/machines/serverle/wifi.nix similarity index 100% rename from nixos/serverle/wifi.nix rename to machines/serverle/wifi.nix diff --git a/machines/thinkman/configuration.nix b/machines/thinkman/configuration.nix new file mode 100644 index 0000000..3f2122b --- /dev/null +++ b/machines/thinkman/configuration.nix @@ -0,0 +1,71 @@ +{ config, pkgs, lib, ... }: +{ + imports = [ + ./disks.nix + ./hardware-configuration.nix + ./services.nix + ../../legacy/modules/3d-design.nix + ../../legacy/modules/android.nix + ../../legacy/modules/avahi.nix + ../../legacy/modules/bluetooth-audio.nix + ../../legacy/modules/clean.nix + ../../legacy/modules/desktop-default.nix + ../../legacy/modules/desktop-development.nix + ../../legacy/modules/development.nix + ../../legacy/modules/docker.nix + ../../legacy/modules/filesystem.nix + ../../legacy/modules/gaming.nix + ../../legacy/modules/hardware-base.nix + ../../legacy/modules/intel-video.nix + ../../legacy/modules/intel.nix + ../../legacy/modules/kvm.nix + ../../legacy/modules/location.nix + ../../legacy/modules/media.nix + ../../legacy/modules/meeting.nix + ../../legacy/modules/nix.nix + ../../legacy/modules/power.nix + ../../legacy/modules/presentation.nix + ../../legacy/modules/printer.nix + ../../legacy/modules/screen-sharing.nix + ../../legacy/modules/sway.nix + ../../legacy/modules/sync.nix + ../../legacy/modules/systemd-user.nix + ../../legacy/modules/systemduefi.nix + ../../legacy/modules/tex.nix + ../../legacy/modules/thunderbolt.nix + ../../legacy/modules/webcam.nix + ]; + + networking.hostName = "thinkman"; + + sops = { + defaultSopsFile = ./secrets.yaml; + age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + gnupg.sshKeyPaths = [ ]; + }; + + nix.extraOptions = '' + extra-platforms = aarch64-linux i686-linux + ''; + boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + + # Use latest kernel + boot.kernelPackages = pkgs.linuxPackages_latest; + + # Nix + nix = { + autoOptimiseStore = true; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + daemonCPUSchedPolicy = "idle"; + daemonIOSchedPriority = 7; + }; + + system = { + stateVersion = "22.05"; + autoUpgrade.enable = true; + }; +} diff --git a/nixos/thinkman/disks.nix b/machines/thinkman/disks.nix similarity index 100% rename from nixos/thinkman/disks.nix rename to machines/thinkman/disks.nix diff --git a/nixos/thinkman/hardware-configuration.nix b/machines/thinkman/hardware-configuration.nix similarity index 100% rename from nixos/thinkman/hardware-configuration.nix rename to machines/thinkman/hardware-configuration.nix diff --git a/nixos/thinkman/secrets.yaml b/machines/thinkman/secrets.yaml similarity index 100% rename from nixos/thinkman/secrets.yaml rename to machines/thinkman/secrets.yaml diff --git a/nixos/thinkman/services.nix b/machines/thinkman/services.nix similarity index 100% rename from nixos/thinkman/services.nix rename to machines/thinkman/services.nix diff --git a/nixos/thinkman/configuration.nix b/nixos/thinkman/configuration.nix deleted file mode 100644 index 705b3c0..0000000 --- a/nixos/thinkman/configuration.nix +++ /dev/null @@ -1,71 +0,0 @@ -{ config, pkgs, lib, ... }: -{ - imports = [ - ./disks.nix - ./hardware-configuration.nix - ./services.nix - ../modules/3d-design.nix - ../modules/android.nix - ../modules/avahi.nix - ../modules/bluetooth-audio.nix - ../modules/clean.nix - ../modules/desktop-default.nix - ../modules/desktop-development.nix - ../modules/development.nix - ../modules/docker.nix - ../modules/filesystem.nix - ../modules/gaming.nix - ../modules/hardware-base.nix - ../modules/intel-video.nix - ../modules/intel.nix - ../modules/kvm.nix - ../modules/location.nix - ../modules/media.nix - ../modules/meeting.nix - ../modules/nix.nix - ../modules/power.nix - ../modules/presentation.nix - ../modules/printer.nix - ../modules/screen-sharing.nix - ../modules/sway.nix - ../modules/sync.nix - ../modules/systemd-user.nix - ../modules/systemduefi.nix - ../modules/tex.nix - ../modules/thunderbolt.nix - ../modules/webcam.nix - ]; - - networking.hostName = "thinkman"; - - sops = { - defaultSopsFile = ./secrets.yaml; - age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; - gnupg.sshKeyPaths = [ ]; - }; - - nix.extraOptions = '' - extra-platforms = aarch64-linux i686-linux - ''; - boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; - - # Use latest kernel - boot.kernelPackages = pkgs.linuxPackages_latest; - - # Nix - nix = { - autoOptimiseStore = true; - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - daemonCPUSchedPolicy = "idle"; - daemonIOSchedPriority = 7; - }; - - system = { - stateVersion = "22.05"; - autoUpgrade.enable = true; - }; -}