From 36a874e400776ab0348e33d4adca19c90b45937a Mon Sep 17 00:00:00 2001 From: Swarsel Date: Sun, 21 Jul 2024 16:11:07 +0200 Subject: [PATCH] feat: provide support for more archtectures --- SwarselSystems.org | 328 ++++++------- flake.nix | 211 ++++----- index.html | 966 +++++++++++++++++++------------------- overlays/default.nix | 24 + pkgs/default.nix | 1 + profiles/common/nixos.nix | 2 +- 6 files changed, 756 insertions(+), 776 deletions(-) create mode 100644 overlays/default.nix create mode 100644 pkgs/default.nix diff --git a/SwarselSystems.org b/SwarselSystems.org index 3b4e973..c7100d9 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -377,7 +377,7 @@ Handling the flake.nix file used to be a bit of a chore, since it felt like writ These blocks are later inserted here: [[#h:aee5ec75-7ca6-40d8-b6ac-a3e7e33a474b][flake.nix template]]. Adding new flake inputs is very easy, you just add them to [[#h:8a411ee2-a58e-4b5b-99bd-4ba772f8f0a2][Inputs & Inputs@Outputs]] first by name in the first source-block, and then the path in the second source-block. Any variables to be set for the host configuration are done in [[#h:df0072bc-853f-438f-bd85-bfc869501015][let]], and the specific setup is done in either [[#h:9c9b9e3b-8771-44fa-ba9e-5056ae809655][nixosConfigurations]] (for NixOS systems), [[#h:f881aa05-a670-48dd-a57b-2916abdcb692][homeConfigurations]] (for home-manager systems), or [[#h:5f6ef553-59f9-4239-b6f3-63d33b57f335][nixOnDroidConfigurations]] (for Nix on Android). There is also the [[#h:6a08495a-8566-4bb5-9fac-b03df01f6c81][nixos-generators]] section that currently just defines a Proxmox LXC image. -*** Inputs & Inputs@Outputs +*** Inputs :PROPERTIES: :CUSTOM_ID: h:8a411ee2-a58e-4b5b-99bd-4ba772f8f0a2 :END: @@ -388,26 +388,6 @@ Format: , Mind the comma at the end. You need this because the =...= is being passed as the last argument in the template at [[#h:aee5ec75-7ca6-40d8-b6ac-a3e7e33a474b][flake.nix template]]. -#+begin_src nix :tangle no :noweb-ref flakeinputsatoutputs - - nixpkgs, - nixpkgs-stable, - home-manager, - nix-on-droid, - emacs-overlay, - nur, - nixgl, - stylix, - sops-nix, - lanzaboote, - nixos-hardware, - nix-alien, - nixos-generators, - nswitch-rcm-nix, - nix-index-database, - -#+end_src - Here, just add the input names, urls and other options that are needed, like =nixpkgs.follows=. By using the latter option, you tell the package to not provide it's own package repository, but instead 'nest' itself into another, which is very useful. A short overview over each input and what it does: @@ -519,50 +499,74 @@ Lastly I define some common module lists that I can simply load depending on the #+begin_src nix :tangle no :noweb-ref flakelet - system = "x86_64-linux"; # not very portable, but I do not use other architectures at the moment - pkgs = import nixpkgs { - inherit system; - overlays = [ - emacs-overlay.overlay - nur.overlay - nixgl.overlay - (final: _prev: { - stable = import nixpkgs-stable { - inherit (final) system config; - }; - }) - ]; - config.allowUnfree = true; - }; + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; # NixOS modules that can only be used on NixOS systems nixModules = [ - stylix.nixosModules.stylix - sops-nix.nixosModules.sops - nswitch-rcm-nix.nixosModules.nswitch-rcm - ./profiles/common/nixos.nix - # dynamic library loading - ({ self, system, ... }: { - environment.systemPackages = with self.inputs.nix-alien.packages.${system}; [ - nix-alien - ]; - # needed for `nix-alien-ld` - programs.nix-ld.enable = true; + ({ ... }: { nix.extraOptions = "experimental-features = nix-command flakes"; }) + ({ inputs, config, ... }: { + nixpkgs = { + overlays = [ + (import ./overlays { inherit inputs; }).additions + (import ./overlays { inherit inputs; }).modifications + (import ./overlays { inherit inputs; }).nixpkgs-stable + inputs.nur.overlay + inputs.emacs-overlay.overlay + inputs.nixgl.overlay + ]; + config.allowUnfree = true; + }; }) + inputs.stylix.nixosModules.stylix + inputs.sops-nix.nixosModules.sops + inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm + ./profiles/common/nixos.nix ]; # Home-Manager modules wanted on non-NixOS systems homeModules = [ - stylix.homeManagerModules.stylix + inputs.stylix.homeManagerModules.stylix ]; + # Home-Manager modules wanted on both NixOS and non-NixOS systems mixedModules = [ - sops-nix.homeManagerModules.sops - nix-index-database.hmModules.nix-index + inputs.sops-nix.homeManagerModules.sops + inputs.nix-index-database.hmModules.nix-index ./profiles/common/home.nix ]; #+end_src +*** General (outputs) + +#+begin_src nix :tangle no :noweb-ref flakeoutputgeneral + + packages = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; in import ./pkgs { inherit pkgs; }); + devShells = forAllSystems + (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShell { + # Enable experimental features without having to specify the argument + NIX_CONFIG = "experimental-features = nix-command flakes"; + nativeBuildInputs = [ pkgs.nix pkgs.home-manager pkgs.git ]; + }; + }); + formatter = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in pkgs.nixpkgs-fmt); + overlays = import ./overlays { inherit inputs; }; + + +#+end_src + *** nixosConfigurations :PROPERTIES: :CUSTOM_ID: h:9c9b9e3b-8771-44fa-ba9e-5056ae809655 @@ -572,46 +576,21 @@ This section is the biggest pain point of the configuration. For every system, I #+begin_src nix :tangle no :noweb-ref flakenixosconf - onett = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profles/onett/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/onett/home.nix - ]; - } - ]; - }; sandbox = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/sandbox/nixos.nix ]; }; - twoson = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profiles/twoson/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/twoson/home.nix - ]; - } - ]; - }; - threed = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = nixModules ++ [ - lanzaboote.nixosModules.lanzaboote + inputs.lanzaboote.nixosModules.lanzaboote ./profiles/threed/nixos.nix - home-manager.nixosModules.home-manager + inputs.home-manager.nixosModules.home-manager { home-manager.users.swarsel.imports = mixedModules ++ [ ./profiles/threed/home.nix @@ -621,11 +600,11 @@ This section is the biggest pain point of the configuration. For every system, I }; fourside = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2 + specialArgs = { inherit inputs; }; + modules = nixModules ++ [ + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2 ./profiles/fourside/nixos.nix - home-manager.nixosModules.home-manager + inputs.home-manager.nixosModules.home-manager { home-manager.users.swarsel.imports = mixedModules ++ [ ./profiles/fourside/home.nix @@ -635,11 +614,11 @@ This section is the biggest pain point of the configuration. For every system, I }; winters = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = nixModules ++ [ - nixos-hardware.nixosModules.framework-16-inch-7040-amd + inputs.nixos-hardware.nixosModules.framework-16-inch-7040-amd ./profiles/winters/nixos.nix - home-manager.nixosModules.home-manager + inputs.home-manager.nixosModules.home-manager { home-manager.users.swarsel.imports = mixedModules ++ [ ./profiles/winters/home.nix @@ -648,99 +627,83 @@ This section is the biggest pain point of the configuration. For every system, I ]; }; - stand = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profiles/stand/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.homelen.imports = mixedModules ++ [ - ./profiles/stand/home.nix - ]; - } - ]; - }; - nginx = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/nginx/nixos.nix ]; }; calibre = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/calibre/nixos.nix ]; }; jellyfin = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - # sops-nix.nixosModules.sops ./profiles/server1/jellyfin/nixos.nix ]; }; transmission = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/transmission/nixos.nix ]; }; matrix = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - # this is to import a service module that is not on nixpkgs - # this way avoids infinite recursion errors + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/matrix/nixos.nix ]; }; sound = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/sound/nixos.nix ]; }; spotifyd = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/spotifyd/nixos.nix ]; }; paperless = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/paperless/nixos.nix ]; }; #ovm swarsel sync = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/remote/oracle/sync/nixos.nix ]; }; #ovm swarsel swatrix = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/remote/oracle/matrix/nixos.nix ]; }; @@ -754,8 +717,7 @@ In contrast, this defines home-manager systems, which I only have one of. #+begin_src nix :tangle no :noweb-ref flakehomeconf - "leons@PCisLee" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; + "leons@PCisLee" = inputs.home-manager.lib.homeManagerConfiguration { modules = homeModules ++ mixedModules ++ [ ./profiles/surface/home.nix ]; @@ -772,7 +734,7 @@ Nix on Android also demands an own flake output, which is provided here. #+begin_src nix :tangle no :noweb-ref flakedroidconf - default = nix-on-droid.lib.nixOnDroidConfiguration { + default = inputs.nix-on-droid.lib.nixOnDroidConfiguration { modules = [ ./profiles/mysticant/configuration.nix ]; @@ -799,7 +761,7 @@ The resulting image can then be loaded in Proxmox. #+begin_src nix :tangle no :noweb-ref flakenixosgenerators - proxmox-lxc = nixos-generators.nixosGenerate { + proxmox-lxc = inputs.nixos-generators.nixosGenerate { inherit system; modules = [ ./profiles/server1/TEMPLATE/nixos.nix @@ -4289,6 +4251,57 @@ Lastly, the machine that runs matrix needs to regularly update, as otherwise you } +#+end_src +** Manual Overlays and packages + +In this section I define packages that I manually want to nixpkgs. This can be useful for packages that are currently awaiting a PR or public packages that I do not want to maintain. + +As such, I also define three additional overlays: + +1) =additions= + These are for the aforementioned added packages +2) =modification= + These are for packages that are on nixpkgs, but do not fit my usecase, meaning I need to perform modifications on them. +3) =nixpkgs-stable= + This is simply a mirror of the most recent stable branch of nixpkgs. Useful for packages that are broken on nixpkgs, but do not need to be on bleeding edge anyways. + +*** pkgs + +#+begin_src nix :tangle pkgs/default.nix + +{ ... }: { } + +#+end_src + +*** Overlays + +#+begin_src nix :tangle overlays/default.nix + + { inputs, ... }: { + additions = final: _prev: import ../pkgs { pkgs = final; }; + modifications = final: _prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + + # river = prev.river.overrideAttrs (oldAttrs: rec { + # pname = "river"; + # version = "git"; + # src = prev.fetchFromGitHub { + # owner = "riverwm"; + # repo = pname; + # rev = "c16628c7f57c51d50f2d10a96c265fb0afaddb02"; + # hash = "sha256-E3Xtv7JeCmafiNmpuS5VuLgh1TDAbibPtMo6A9Pz6EQ="; + # fetchSubmodules = true; + # }; + # }); + }; + + nixpkgs-stable = final: _prev: { + stable = import inputs.nixpkgs-stable { inherit (final) system; }; + }; +} + #+end_src ** Common NixOS @@ -4349,7 +4362,7 @@ Next, we need to make sure that flakes stay enabled when we rebuild the configur #+begin_src nix :tangle profiles/common/nixos.nix - nix.settings.experimental-features = ["nix-command" "flakes"]; + # nix.settings.experimental-features = ["nix-command" "flakes"]; #+end_src @@ -7124,42 +7137,43 @@ This tangles the flake.nix file; This block only needs to be touched when updati <> }; - outputs = inputs@{ - <> - ... - }: let - <> - in { + outputs = + inputs@{ self + , nixpkgs + , ... + }: + let + <> + in + { + <> + # NixOS setups - run home-manager as a NixOS module for better compatibility + # another benefit - full rebuild on nixos-rebuild switch + # run rebuild using `nswitch` - # NixOS setups - run home-manager as a NixOS module for better compatibility - # another benefit - full rebuild on nixos-rebuild switch - # run rebuild using `nswitch` + # NEW HOSTS: For a new host, decide whether a NixOS (nixosConfigurations) or non-NixOS (homeConfigurations) is used. + # Make sure to move hardware-configuration to the appropriate location, by default it is found in /etc/nixos/. - # NEW HOSTS: For a new host, decide whether a NixOS (nixosConfigurations) or non-NixOS (homeConfigurations) is used. - # Make sure to move hardware-configuration to the appropriate location, by default it is found in /etc/nixos/. + nixosConfigurations = { + <> + }; + + # pure Home Manager setups - for non-NixOS machines + # run rebuild using `hmswitch` + + homeConfigurations = { + <> + }; + + nixOnDroidConfigurations = { + <> + }; - nixosConfigurations = { - <> }; - - # pure Home Manager setups - for non-NixOS machines - # run rebuild using `hmswitch` - - homeConfigurations = { - <> - }; - - nixOnDroidConfigurations = { - <> - }; - - packages.x86_64-linux = { - <> - }; - - }; } + + #+end_src * Emacs :PROPERTIES: diff --git a/flake.nix b/flake.nix index f173dbc..8669bb9 100644 --- a/flake.nix +++ b/flake.nix @@ -72,71 +72,76 @@ }; outputs = - inputs@{ nixpkgs - , nixpkgs-stable - , home-manager - , nix-on-droid - , emacs-overlay - , nur - , nixgl - , stylix - , sops-nix - , lanzaboote - , nixos-hardware - , nix-alien - , nixos-generators - , nswitch-rcm-nix - , nix-index-database + inputs@{ self + , nixpkgs , ... }: let - system = "x86_64-linux"; # not very portable, but I do not use other architectures at the moment - pkgs = import nixpkgs { - inherit system; - overlays = [ - emacs-overlay.overlay - nur.overlay - nixgl.overlay - (final: _prev: { - stable = import nixpkgs-stable { - inherit (final) system config; - }; - }) - ]; - config.allowUnfree = true; - }; + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; # NixOS modules that can only be used on NixOS systems nixModules = [ - stylix.nixosModules.stylix - sops-nix.nixosModules.sops - nswitch-rcm-nix.nixosModules.nswitch-rcm - ./profiles/common/nixos.nix - # dynamic library loading - ({ self, system, ... }: { - environment.systemPackages = with self.inputs.nix-alien.packages.${system}; [ - nix-alien - ]; - # needed for `nix-alien-ld` - programs.nix-ld.enable = true; + ({ ... }: { nix.extraOptions = "experimental-features = nix-command flakes"; }) + ({ inputs, config, ... }: { + nixpkgs = { + overlays = [ + (import ./overlays { inherit inputs; }).additions + (import ./overlays { inherit inputs; }).modifications + (import ./overlays { inherit inputs; }).nixpkgs-stable + inputs.nur.overlay + inputs.emacs-overlay.overlay + inputs.nixgl.overlay + ]; + config.allowUnfree = true; + }; }) + inputs.stylix.nixosModules.stylix + inputs.sops-nix.nixosModules.sops + inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm + ./profiles/common/nixos.nix ]; # Home-Manager modules wanted on non-NixOS systems homeModules = [ - stylix.homeManagerModules.stylix + inputs.stylix.homeManagerModules.stylix ]; + # Home-Manager modules wanted on both NixOS and non-NixOS systems mixedModules = [ - sops-nix.homeManagerModules.sops - nix-index-database.hmModules.nix-index + inputs.sops-nix.homeManagerModules.sops + inputs.nix-index-database.hmModules.nix-index ./profiles/common/home.nix ]; in { + packages = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; in import ./pkgs { inherit pkgs; }); + devShells = forAllSystems + (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShell { + # Enable experimental features without having to specify the argument + NIX_CONFIG = "experimental-features = nix-command flakes"; + nativeBuildInputs = [ pkgs.nix pkgs.home-manager pkgs.git ]; + }; + }); + formatter = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in pkgs.nixpkgs-fmt); + overlays = import ./overlays { inherit inputs; }; + + # NixOS setups - run home-manager as a NixOS module for better compatibility # another benefit - full rebuild on nixos-rebuild switch # run rebuild using `nswitch` @@ -146,46 +151,21 @@ nixosConfigurations = { - onett = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profles/onett/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/onett/home.nix - ]; - } - ]; - }; sandbox = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/sandbox/nixos.nix ]; }; - twoson = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profiles/twoson/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/twoson/home.nix - ]; - } - ]; - }; - threed = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = nixModules ++ [ - lanzaboote.nixosModules.lanzaboote + inputs.lanzaboote.nixosModules.lanzaboote ./profiles/threed/nixos.nix - home-manager.nixosModules.home-manager + inputs.home-manager.nixosModules.home-manager { home-manager.users.swarsel.imports = mixedModules ++ [ ./profiles/threed/home.nix @@ -195,11 +175,11 @@ }; fourside = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = nixModules ++ [ - nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2 + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2 ./profiles/fourside/nixos.nix - home-manager.nixosModules.home-manager + inputs.home-manager.nixosModules.home-manager { home-manager.users.swarsel.imports = mixedModules ++ [ ./profiles/fourside/home.nix @@ -209,11 +189,11 @@ }; winters = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = nixModules ++ [ - nixos-hardware.nixosModules.framework-16-inch-7040-amd + inputs.nixos-hardware.nixosModules.framework-16-inch-7040-amd ./profiles/winters/nixos.nix - home-manager.nixosModules.home-manager + inputs.home-manager.nixosModules.home-manager { home-manager.users.swarsel.imports = mixedModules ++ [ ./profiles/winters/home.nix @@ -222,99 +202,83 @@ ]; }; - stand = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profiles/stand/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.homelen.imports = mixedModules ++ [ - ./profiles/stand/home.nix - ]; - } - ]; - }; - nginx = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/nginx/nixos.nix ]; }; calibre = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/calibre/nixos.nix ]; }; jellyfin = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - # sops-nix.nixosModules.sops ./profiles/server1/jellyfin/nixos.nix ]; }; transmission = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/transmission/nixos.nix ]; }; matrix = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - # this is to import a service module that is not on nixpkgs - # this way avoids infinite recursion errors + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/matrix/nixos.nix ]; }; sound = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/sound/nixos.nix ]; }; spotifyd = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/spotifyd/nixos.nix ]; }; paperless = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/server1/paperless/nixos.nix ]; }; #ovm swarsel sync = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/remote/oracle/sync/nixos.nix ]; }; #ovm swarsel swatrix = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; + specialArgs = { inherit inputs; }; modules = [ - sops-nix.nixosModules.sops + inputs.sops-nix.nixosModules.sops ./profiles/remote/oracle/matrix/nixos.nix ]; }; @@ -325,8 +289,7 @@ homeConfigurations = { - "leons@PCisLee" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; + "leons@PCisLee" = inputs.home-manager.lib.homeManagerConfiguration { modules = homeModules ++ mixedModules ++ [ ./profiles/surface/home.nix ]; @@ -336,7 +299,7 @@ nixOnDroidConfigurations = { - default = nix-on-droid.lib.nixOnDroidConfiguration { + default = inputs.nix-on-droid.lib.nixOnDroidConfiguration { modules = [ ./profiles/mysticant/configuration.nix ]; @@ -344,17 +307,5 @@ }; - packages.x86_64-linux = { - - proxmox-lxc = nixos-generators.nixosGenerate { - inherit system; - modules = [ - ./profiles/server1/TEMPLATE/nixos.nix - ]; - format = "proxmox-lxc"; - }; - - }; - }; } diff --git a/index.html b/index.html index 8502481..4e9d59d 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + SwarselSystems: NixOS + Emacs Configuration @@ -221,12 +221,13 @@
  • 2.3. flake.nix
  • @@ -240,48 +241,54 @@
  • 3.1.3. Virtual hosts
  • -
  • 3.2. Common NixOS +
  • 3.2. Manual Overlays and packages
  • -
  • 3.3. Common Home-Manager +
  • 3.3. Common NixOS
  • -
  • 3.4. flake.nix template and Closing Parenthesis (this needs to be the last heading in the Systems header) +
  • 3.4. Common Home-Manager +
  • +
  • 3.5. flake.nix template and Closing Parenthesis (this needs to be the last heading in the Systems header) +
  • @@ -329,7 +336,7 @@
    • 4.4.1. Org Mode
    • 4.4.2. Nix Mode
    • -
    • 4.4.3. nixpkgs-fmt
    • +
    • 4.4.3. nixpkgs-fmt
    • 4.4.4. Markdown Mode
    • 4.4.5. Olivetti
    • 4.4.6. darkroom
    • @@ -389,7 +396,7 @@

      -This file has 41360 words spanning 11032 lines and was last revised on 2024-07-20 15:47:39 +0200. +This file has 41470 words spanning 11046 lines and was last revised on 2024-07-21 15:56:32 +0200.

      @@ -439,7 +446,7 @@ This section defines my Emacs configuration. For a while, I considered to use ry

      -My emacs is built using the emacs-overlay nix flake, which builds a bleeding edge emacs on wayland (pgtk) with utilities like treesitter support. By executing the below source block, the current build setting can be updated at any time, and you can see my most up-to-date build options (last updated: 2024-07-20 15:47:39 +0200) +My emacs is built using the emacs-overlay nix flake, which builds a bleeding edge emacs on wayland (pgtk) with utilities like treesitter support. By executing the below source block, the current build setting can be updated at any time, and you can see my most up-to-date build options (last updated: 2024-07-21 15:56:32 +0200)

    @@ -872,7 +879,7 @@ These blocks are later inserted here: -

    2.3.1. Inputs & Inputs@Outputs

    +

    2.3.1. Inputs

    Here we define inputs and outputs of the flake. First, the following list is for the outputs of the flake. @@ -886,27 +893,6 @@ Format: <name>, Mind the comma at the end. You need this because the ... is being passed as the last argument in the template at flake.nix template.

    -
    -
    -nixpkgs,
    -nixpkgs-stable,
    -home-manager,
    -nix-on-droid,
    -emacs-overlay,
    -nur,
    -nixgl,
    -stylix,
    -sops-nix,
    -lanzaboote,
    -nixos-hardware,
    -nix-alien,
    -nixos-generators,
    -nswitch-rcm-nix,
    -nix-index-database,
    -
    -
    -
    -

    Here, just add the input names, urls and other options that are needed, like nixpkgs.follows. By using the latter option, you tell the package to not provide it's own package repository, but instead 'nest' itself into another, which is very useful. A short overview over each input and what it does: @@ -1027,55 +1013,82 @@ Lastly I define some common module lists that I can simply load depending on the

    -system = "x86_64-linux"; # not very portable, but I do not use other architectures at the moment
    -pkgs = import nixpkgs {
    -  inherit system;
    -  overlays = [
    -    emacs-overlay.overlay
    -    nur.overlay
    -    nixgl.overlay
    -    (final: _prev: {
    -      stable = import nixpkgs-stable {
    -        inherit (final) system config;
    -      };
    -    })
    -  ];
    -  config.allowUnfree = true;
    -};
    +forAllSystems = nixpkgs.lib.genAttrs [
    +      "aarch64-linux"
    +      "i686-linux"
    +      "x86_64-linux"
    +      "aarch64-darwin"
    +      "x86_64-darwin"
    +    ];
     
     # NixOS modules that can only be used on NixOS systems
     nixModules = [
    -  stylix.nixosModules.stylix
    -  sops-nix.nixosModules.sops
    -  nswitch-rcm-nix.nixosModules.nswitch-rcm
    -  ./profiles/common/nixos.nix
    -  # dynamic library loading
    -  ({ self, system, ... }: {
    -    environment.systemPackages = with self.inputs.nix-alien.packages.${system}; [
    -      nix-alien
    -    ];
    -    # needed for `nix-alien-ld`
    -    programs.nix-ld.enable = true;
    +  ({ ... }: { nix.extraOptions = "experimental-features = nix-command flakes"; })
    +  ({ inputs, config, ... }: {
    +    nixpkgs = {
    +      overlays = [
    +        (import ./overlays { inherit inputs; }).additions
    +        (import ./overlays { inherit inputs; }).modifications
    +        (import ./overlays { inherit inputs; }).nixpkgs-stable
    +        inputs.nur.overlay
    +        inputs.emacs-overlay.overlay
    +        inputs.nixgl.overlay
    +      ];
    +      config.allowUnfree = true;
    +    };
       })
    +  inputs.stylix.nixosModules.stylix
    +  inputs.sops-nix.nixosModules.sops
    +  inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm
    +  ./profiles/common/nixos.nix
     ];
     
     # Home-Manager modules wanted on non-NixOS systems
     homeModules = [
    -  stylix.homeManagerModules.stylix
    +  inputs.stylix.homeManagerModules.stylix
     ];
    +
     # Home-Manager modules wanted on both NixOS and non-NixOS systems
     mixedModules = [
    -  sops-nix.homeManagerModules.sops
    -  nix-index-database.hmModules.nix-index
    +  inputs.sops-nix.homeManagerModules.sops
    +  inputs.nix-index-database.hmModules.nix-index
       ./profiles/common/home.nix
     ];
     
    +
    +
    +
    + +
    +

    2.3.3. General (outputs)

    +
    +
    +
    +packages = forAllSystems (system:
    +  let pkgs = nixpkgs.legacyPackages.${system}; in import ./pkgs { inherit pkgs; });
    +devShells = forAllSystems
    +  (system:
    +    let pkgs = nixpkgs.legacyPackages.${system};
    +    in
    +    {
    +      default = pkgs.mkShell {
    +        # Enable experimental features without having to specify the argument
    +        NIX_CONFIG = "experimental-features = nix-command flakes";
    +        nativeBuildInputs = [ pkgs.nix pkgs.home-manager pkgs.git ];
    +      };
    +    });
    +formatter = forAllSystems (system:
    +  let pkgs = nixpkgs.legacyPackages.${system};
    +  in pkgs.nixpkgs-fmt);
    +overlays = import ./overlays { inherit inputs; };
    +
    +
     
    -

    2.3.3. nixosConfigurations

    +

    2.3.4. nixosConfigurations

    This section is the biggest pain point of the configuration. For every system, I have one of these. I know there are better ways to go about this, but I did not find the time yet to look into this further. For now, enjoy this meter-long list @@ -1083,46 +1096,21 @@ This section is the biggest pain point of the configuration. For every system, I

    -onett = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    -  modules = nixModules ++ [
    -    ./profles/onett/nixos.nix
    -    home-manager.nixosModules.home-manager
    -    {
    -      home-manager.users.swarsel.imports = mixedModules ++ [
    -        ./profiles/onett/home.nix
    -      ];
    -    }
    -  ];
    -};
     
     sandbox = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/sandbox/nixos.nix
       ];
     };
     
    -twoson = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    -  modules = nixModules ++ [
    -    ./profiles/twoson/nixos.nix
    -    home-manager.nixosModules.home-manager
    -    {
    -      home-manager.users.swarsel.imports = mixedModules ++ [
    -        ./profiles/twoson/home.nix
    -      ];
    -    }
    -  ];
    -};
    -
     threed = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = nixModules ++ [
    -    lanzaboote.nixosModules.lanzaboote
    +    inputs.lanzaboote.nixosModules.lanzaboote
         ./profiles/threed/nixos.nix
    -    home-manager.nixosModules.home-manager
    +    inputs.home-manager.nixosModules.home-manager
         {
           home-manager.users.swarsel.imports = mixedModules ++ [
             ./profiles/threed/home.nix
    @@ -1132,11 +1120,11 @@ threed = nixpkgs.lib.nixosSystem {
     };
     
     fourside = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    -  modules = nixModules ++ [
    -    nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2
    +  specialArgs = { inherit inputs; };
    +  modules = nixModules ++  [
    +    inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2
         ./profiles/fourside/nixos.nix
    -    home-manager.nixosModules.home-manager
    +    inputs.home-manager.nixosModules.home-manager
         {
           home-manager.users.swarsel.imports = mixedModules ++ [
             ./profiles/fourside/home.nix
    @@ -1146,11 +1134,11 @@ fourside = nixpkgs.lib.nixosSystem {
     };
     
     winters = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = nixModules ++ [
    -    nixos-hardware.nixosModules.framework-16-inch-7040-amd
    +    inputs.nixos-hardware.nixosModules.framework-16-inch-7040-amd
         ./profiles/winters/nixos.nix
    -    home-manager.nixosModules.home-manager
    +    inputs.home-manager.nixosModules.home-manager
         {
           home-manager.users.swarsel.imports = mixedModules ++ [
             ./profiles/winters/home.nix
    @@ -1159,99 +1147,83 @@ winters = nixpkgs.lib.nixosSystem {
       ];
     };
     
    -stand = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    -  modules = nixModules ++ [
    -    ./profiles/stand/nixos.nix
    -    home-manager.nixosModules.home-manager
    -    {
    -      home-manager.users.homelen.imports = mixedModules ++ [
    -        ./profiles/stand/home.nix
    -      ];
    -    }
    -  ];
    -};
    -
     nginx = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/server1/nginx/nixos.nix
       ];
     };
     
     calibre = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/server1/calibre/nixos.nix
       ];
     };
     
     jellyfin = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    # sops-nix.nixosModules.sops
         ./profiles/server1/jellyfin/nixos.nix
       ];
     };
     
     transmission = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/server1/transmission/nixos.nix
       ];
     };
     
     matrix = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    -  # this is to import a service module that is not on nixpkgs
    -  # this way avoids infinite recursion errors
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/server1/matrix/nixos.nix
       ];
     };
     
     sound = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/server1/sound/nixos.nix
       ];
     };
     
     spotifyd = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/server1/spotifyd/nixos.nix
       ];
     };
     
     paperless = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/server1/paperless/nixos.nix
       ];
     };
     
     #ovm swarsel
     sync = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/remote/oracle/sync/nixos.nix
       ];
     };
     
     #ovm swarsel
     swatrix = nixpkgs.lib.nixosSystem {
    -  specialArgs = { inherit inputs pkgs; };
    +  specialArgs = { inherit inputs; };
       modules = [
    -    sops-nix.nixosModules.sops
    +    inputs.sops-nix.nixosModules.sops
         ./profiles/remote/oracle/matrix/nixos.nix
       ];
     };
    @@ -1260,7 +1232,7 @@ swatrix = nixpkgs.lib.nixosSystem {
     
    -

    2.3.4. homeConfigurations

    +

    2.3.5. homeConfigurations

    In contrast, this defines home-manager systems, which I only have one of. @@ -1268,8 +1240,7 @@ In contrast, this defines home-manager systems, which I only have one of.

    -"leons@PCisLee" = home-manager.lib.homeManagerConfiguration {
    -  inherit pkgs;
    +"leons@PCisLee" = inputs.home-manager.lib.homeManagerConfiguration {
       modules = homeModules ++ mixedModules ++ [
         ./profiles/surface/home.nix
       ];
    @@ -1280,7 +1251,7 @@ In contrast, this defines home-manager systems, which I only have one of.
     
    -

    2.3.5. nixOnDroidConfigurations

    +

    2.3.6. nixOnDroidConfigurations

    Nix on Android also demands an own flake output, which is provided here. @@ -1288,7 +1259,7 @@ Nix on Android also demands an own flake output, which is provided here.

    -default = nix-on-droid.lib.nixOnDroidConfiguration {
    +default = inputs.nix-on-droid.lib.nixOnDroidConfiguration {
       modules = [
         ./profiles/mysticant/configuration.nix
       ];
    @@ -1299,7 +1270,7 @@ default = nix-on-droid.lib.nixOnDroidConfiguration {
     
    -

    2.3.6. nixos-generators

    +

    2.3.7. nixos-generators

    This builds my proxmox template. It is defined as a separate output so that I can already apply some rudimentary configuration before even setting up the system. @@ -1322,7 +1293,7 @@ The resulting image can then be loaded in Proxmox.

    -proxmox-lxc = nixos-generators.nixosGenerate {
    +proxmox-lxc = inputs.nixos-generators.nixosGenerate {
       inherit system;
       modules = [
          ./profiles/server1/TEMPLATE/nixos.nix
    @@ -5440,15 +5411,81 @@ in
     
     
    +
    +

    3.2. Manual Overlays and packages

    +
    +

    +In this section I define packages that I manually want to nixpkgs. This can be useful for packages that are currently awaiting a PR or public packages that I do not want to maintain. +

    + +

    +As such, I also define three additional overlays: +

    + +
      +
    1. additions +These are for the aforementioned added packages
    2. +
    3. modification +These are for packages that are on nixpkgs, but do not fit my usecase, meaning I need to perform modifications on them.
    4. +
    5. nixpkgs-stable +This is simply a mirror of the most recent stable branch of nixpkgs. Useful for packages that are broken on nixpkgs, but do not need to be on bleeding edge anyways.
    6. +
    +
    +
    +

    3.2.1. pkgs

    +
    +
    +
    +{ ... }: { }
    +
    +
    +
    +
    +
    +
    +

    3.2.2. Overlays

    +
    +
    +
    +  { inputs, ... }: {
    +  additions = final: _prev: import ../pkgs { pkgs = final; };
    +  modifications = final: _prev: {
    +    # example = prev.example.overrideAttrs (oldAttrs: rec {
    +    # ...
    +    # });
    +
    +    # river = prev.river.overrideAttrs (oldAttrs: rec {
    +    #   pname = "river";
    +    #   version = "git";
    +    #   src = prev.fetchFromGitHub {
    +    #     owner = "riverwm";
    +    #     repo = pname;
    +    #     rev = "c16628c7f57c51d50f2d10a96c265fb0afaddb02";
    +    #     hash = "sha256-E3Xtv7JeCmafiNmpuS5VuLgh1TDAbibPtMo6A9Pz6EQ=";
    +    #     fetchSubmodules = true;
    +    #   };
    +    # });
    +  };
    +
    +  nixpkgs-stable = final: _prev: {
    +    stable = import inputs.nixpkgs-stable { inherit (final) system; };
    +  };
    +}
    +
    +
    +
    +
    +
    +
    -

    3.2. Common NixOS

    +

    3.3. Common NixOS

    These are system-level settings specific to NixOS machines. All settings that are required on all machines go here.

    -

    3.2.1. General

    +

    3.3.1. General

      @@ -5499,7 +5536,7 @@ Next, we need to make sure that flakes stay enabled when we rebuild the configur
      -nix.settings.experimental-features = ["nix-command" "flakes"];
      +# nix.settings.experimental-features = ["nix-command" "flakes"];
       
       
      @@ -5927,7 +5964,7 @@ i18n = {
    -

    3.2.2. sops

    +

    3.3.2. sops

    I use sops-nix to handle secrets that I want to have available on my machines at all times. Procedure to add a new machine: @@ -5977,7 +6014,7 @@ sops = {

    -

    3.2.3. System Packages

    +

    3.3.3. System Packages

    Mostly used to install some compilers and lsp's that I want to have available when not using a devShell flake. Most other packages should go in Installed packages. @@ -6069,7 +6106,7 @@ environment.systemPackages = with pkgs; [

    -

    3.2.4. Programs (including zsh setup)

    +

    3.3.4. Programs (including zsh setup)

    Some programs profit from being installed through dedicated NixOS settings on system-level; these go here. Notably the zsh setup goes here and cannot be deleted under any circumstances. @@ -6086,8 +6123,8 @@ programs = {

      -
    1. zsh
      -
      +
    2. zsh
      +

      Do not touch this.

      @@ -6103,8 +6140,8 @@ environment.pathsToLink = [ "/share/zsh" ];
    -
  • syncthing
    -
    +
  • syncthing
    +
     services.syncthing = {
    @@ -6157,7 +6194,7 @@ services.syncthing = {
     
     
    -

    3.2.5. Services

    +

    3.3.5. Services

    Setting up some hardware services as well as keyboard related settings. Here we make sure that we can use the CAPS key as a ESC/CTRL double key, which is a lifesaver. @@ -6295,7 +6332,7 @@ services.interception-tools = {

    -

    3.2.6. Hardware compatibility settings (Yubikey, Ledger) - udev rules

    +

    3.3.6. Hardware compatibility settings (Yubikey, Ledger) - udev rules

    It makes sense to house these settings in their own section, since they are all needed really. Note that the starting of the gpg-agent is done in the sway settings, to also perform this step of the setup for non NixOS-machines at the same time. @@ -6339,7 +6376,7 @@ services.udev.packages = with pkgs; [

    -

    3.2.7. System Login

    +

    3.3.7. System Login

    This section houses the greetd related settings. I do not really want to use a display manager, but it is useful to have setup in some ways - in my case for starting sway on system startup. Notably the default user login setting that is commented out here goes into the system specific settings, make sure to update it there @@ -6372,11 +6409,11 @@ environment.etc."greetd/environments".text = ''

    -

    3.3. Common Home-Manager

    +

    3.4. Common Home-Manager

    -

    3.3.1. Installed packages

    +

    3.4.1. Installed packages

    Here are defined some packages that I would like to use across all my machines. Most of these should not require further setup. Notably the cura package is severely outdated on nixpkgs, so I just fetch a more recent AppImage and run that instead. @@ -6722,7 +6759,7 @@ Programming languages and default lsp's are defined here: -

    3.3.2. sops

    +

    3.4.2. sops

    I use sops-nix to handle secrets that I want to have available on my machines at all times. Procedure to add a new machine: @@ -6760,7 +6797,7 @@ sops = {

    -

    3.3.3. SSH Machines

    +

    3.4.3. SSH Machines

    It is very convenient to have SSH aliases in place for machines that I use. This is mainly used for some server machines and some university clusters. We also enable agent forwarding to have our Yubikey SSH key accessible on the remote host. @@ -6868,7 +6905,7 @@ programs.ssh = {

    -

    3.3.4. Fonts + Theme

    +

    3.4.4. Fonts + Theme

    These section allows home-manager to allow theme settings, and handles some other appearance-related settings like cursor styles. Interestingly, system icons (adwaita) still need to be setup on system-level, and will break if defined here. @@ -6887,7 +6924,7 @@ stylix.targets.emacs.enable = false;

    -

    3.3.5. Desktop Entries

    +

    3.4.5. Desktop Entries

    Some programs lack a dmenu launcher - I define them myself here. @@ -6949,7 +6986,7 @@ xdg.desktopEntries = {

    -

    3.3.6. Linking dotfiles

    +

    3.4.6. Linking dotfiles

    This section should be used in order to symlink already existing configuration files using `home.file` and setting session variables using `home.sessionVariables`. @@ -7000,7 +7037,7 @@ xdg.configFile = {

    -

    3.3.7. Sourcing environment variables

    +

    3.4.7. Sourcing environment variables

    @@ -7013,7 +7050,7 @@ home.sessionVariables = {
     
    -

    3.3.8. Programs

    +

    3.4.8. Programs

    This houses the configurations for all programs managed by home-manager. @@ -7050,9 +7087,9 @@ programs = {

  • -
    -

    3.3.9. nix-index

    -
    +
    +

    3.4.9. nix-index

    +

    nix-index provides a way to find out which packages are provided by which derivations. By default it also comes with a replacement for command-not-found.sh, however, the implementation is based on a channel based setup. I like consistency, so I replace the command with one that provides a flakes-based output.

    @@ -7082,7 +7119,7 @@ programs.nix-index =
    -

    3.3.10. password-store

    +

    3.4.10. password-store

    Enables password store with the pass-otp extension which allows me to store and generate one-time-passwords. @@ -7100,7 +7137,7 @@ programs.password-store = {

    -

    3.3.11. direnv

    +

    3.4.11. direnv

    Enables direnv, which I use for nearly all of my nix dev flakes. @@ -7118,7 +7155,7 @@ programs.direnv = {

    -

    3.3.12. eza

    +

    3.4.12. eza

    Eza provides me with a better ls command and some other useful aliases. @@ -7141,7 +7178,7 @@ programs.eza = {

    -

    3.3.14. Fuzzel

    +

    3.4.14. Fuzzel

    Here I only need to set basic layout options - the rest is being managed by stylix. @@ -7216,7 +7253,7 @@ programs.fuzzel = {

    -

    3.3.15. Starship

    +

    3.4.15. Starship

    Starship makes my zsh look cooler! I have symbols for most programming languages and toolchains, also I build my own powerline. @@ -7333,7 +7370,7 @@ programs.starship = {

    -

    3.3.16. Kitty

    +

    3.4.16. Kitty

    Kitty is the terminal emulator of choice for me, it is nice to configure using nix, fast, and has a nice style. @@ -7360,7 +7397,7 @@ programs.kitty = {

    -

    3.3.17. zsh

    +

    3.4.17. zsh

    zsh is the most convenient shell for me and it happens to be super neat to configure within home manager. @@ -7426,7 +7463,7 @@ programs.zsh = {

    -

    3.3.18. Mail

    +

    3.4.18. Mail

    Normally I use 4 mail accounts - here I set them all up. Three of them are Google accounts (sadly), which are a chore to setup. The last is just a sender account that I setup SMTP for here. @@ -7567,7 +7604,7 @@ accounts.email = {

    -

    3.3.19. Home-manager: Emacs

    +

    3.4.19. Home-manager: Emacs

    By using the emacs-overlay NixOS module, I can install all Emacs packages that I want to use right through NixOS. This is done by passing my init.el file to the configuration which will then be parsed upon system rebuild, looking for use-package sections in the Elisp code. Also I define here the style of Emacs that I want to run - I am going with native Wayland Emacs here (emacs-pgtk). All of the nice options such as tree-sitter support are enabled by default, so I do not need to adjust the build process. @@ -7630,7 +7667,7 @@ programs.emacs = {

    -

    3.3.20. Waybar

    +

    3.4.20. Waybar

    Again I am just using the first bar option here that I was able to find good understandable documentation for. Of note is that the `cpu` section's `format` is not defined here, but in section 1 (since not every machine has the same number of cores) @@ -7842,7 +7879,7 @@ programs.waybar = {

    -

    3.3.21. Firefox

    +

    3.4.21. Firefox

    Setting up firefox along with some policies that are important to me (mostly disabling telemetry related stuff as well as Pocket). I also enable some integrations that enable super useful packages, namely tridactyl and browserpass. @@ -7963,7 +8000,7 @@ programs.firefox = {

    -

    3.3.22. Services

    +

    3.4.22. Services

    Services that can be defined through home-manager should be defined here. @@ -8102,7 +8139,7 @@ group-by=category

    -

    3.3.23. Sway

    +

    3.4.23. Sway

    I am currently using SwayFX, which adds some nice effects to sway, like rounded corners and hiding the separator between title and content of a window. @@ -8386,7 +8423,7 @@ wayland.windowManager.sway = {

    -

    3.4. flake.nix template and Closing Parenthesis (this needs to be the last heading in the Systems header)

    +

    3.5. flake.nix template and Closing Parenthesis (this needs to be the last heading in the Systems header)

    This sections puts together the flake.nix file from the Noweb-Ref blocks section. @@ -8397,7 +8434,7 @@ Here we also close the opening parenthesis of modules/common.nix (home-manager)

    -

    3.4.1. Closing parentheses for common/home.nix and common/nixos.nix

    +

    3.5.1. Closing parentheses for common/home.nix and common/nixos.nix

    @@ -8415,7 +8452,7 @@ Here we also close the opening parenthesis of modules/common.nix (home-manager)
     
    -

    3.4.2. flake.nix

    +

    3.5.2. flake.nix

    This tangles the flake.nix file; This block only needs to be touched when updating the general structure of the flake. For everything else, see the respective noweb-ref block. @@ -8496,294 +8533,247 @@ This tangles the flake.nix file; This block only needs to be touched when updati }; - outputs = inputs@{ + outputs = + inputs@{ self + , nixpkgs + , ... + }: + let - nixpkgs, - nixpkgs-stable, - home-manager, - nix-on-droid, - emacs-overlay, - nur, - nixgl, - stylix, - sops-nix, - lanzaboote, - nixos-hardware, - nix-alien, - nixos-generators, - nswitch-rcm-nix, - nix-index-database, + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; - ... - }: let - - system = "x86_64-linux"; # not very portable, but I do not use other architectures at the moment - pkgs = import nixpkgs { - inherit system; - overlays = [ - emacs-overlay.overlay - nur.overlay - nixgl.overlay - (final: _prev: { - stable = import nixpkgs-stable { - inherit (final) system config; + # NixOS modules that can only be used on NixOS systems + nixModules = [ + ({ ... }: { nix.extraOptions = "experimental-features = nix-command flakes"; }) + ({ inputs, config, ... }: { + nixpkgs = { + overlays = [ + (import ./overlays { inherit inputs; }).additions + (import ./overlays { inherit inputs; }).modifications + (import ./overlays { inherit inputs; }).nixpkgs-stable + inputs.nur.overlay + inputs.emacs-overlay.overlay + inputs.nixgl.overlay + ]; + config.allowUnfree = true; }; }) + inputs.stylix.nixosModules.stylix + inputs.sops-nix.nixosModules.sops + inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm + ./profiles/common/nixos.nix ]; - config.allowUnfree = true; - }; - # NixOS modules that can only be used on NixOS systems - nixModules = [ - stylix.nixosModules.stylix - sops-nix.nixosModules.sops - nswitch-rcm-nix.nixosModules.nswitch-rcm - ./profiles/common/nixos.nix - # dynamic library loading - ({ self, system, ... }: { - environment.systemPackages = with self.inputs.nix-alien.packages.${system}; [ - nix-alien - ]; - # needed for `nix-alien-ld` - programs.nix-ld.enable = true; - }) - ]; + # Home-Manager modules wanted on non-NixOS systems + homeModules = [ + inputs.stylix.homeManagerModules.stylix + ]; - # Home-Manager modules wanted on non-NixOS systems - homeModules = [ - stylix.homeManagerModules.stylix - ]; - # Home-Manager modules wanted on both NixOS and non-NixOS systems - mixedModules = [ - sops-nix.homeManagerModules.sops - nix-index-database.hmModules.nix-index - ./profiles/common/home.nix - ]; + # Home-Manager modules wanted on both NixOS and non-NixOS systems + mixedModules = [ + inputs.sops-nix.homeManagerModules.sops + inputs.nix-index-database.hmModules.nix-index + ./profiles/common/home.nix + ]; - in { + in + { - # NixOS setups - run home-manager as a NixOS module for better compatibility - # another benefit - full rebuild on nixos-rebuild switch - # run rebuild using `nswitch` - - # NEW HOSTS: For a new host, decide whether a NixOS (nixosConfigurations) or non-NixOS (homeConfigurations) is used. - # Make sure to move hardware-configuration to the appropriate location, by default it is found in /etc/nixos/. - - nixosConfigurations = { - - onett = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profles/onett/nixos.nix - home-manager.nixosModules.home-manager + packages = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; in import ./pkgs { inherit pkgs; }); + devShells = forAllSystems + (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/onett/home.nix - ]; - } - ]; + default = pkgs.mkShell { + # Enable experimental features without having to specify the argument + NIX_CONFIG = "experimental-features = nix-command flakes"; + nativeBuildInputs = [ pkgs.nix pkgs.home-manager pkgs.git ]; + }; + }); + formatter = forAllSystems (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in pkgs.nixpkgs-fmt); + overlays = import ./overlays { inherit inputs; }; + + + # NixOS setups - run home-manager as a NixOS module for better compatibility + # another benefit - full rebuild on nixos-rebuild switch + # run rebuild using `nswitch` + + # NEW HOSTS: For a new host, decide whether a NixOS (nixosConfigurations) or non-NixOS (homeConfigurations) is used. + # Make sure to move hardware-configuration to the appropriate location, by default it is found in /etc/nixos/. + + nixosConfigurations = { + + + sandbox = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/sandbox/nixos.nix + ]; + }; + + threed = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = nixModules ++ [ + inputs.lanzaboote.nixosModules.lanzaboote + ./profiles/threed/nixos.nix + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = mixedModules ++ [ + ./profiles/threed/home.nix + ]; + } + ]; + }; + + fourside = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = nixModules ++ [ + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2 + ./profiles/fourside/nixos.nix + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = mixedModules ++ [ + ./profiles/fourside/home.nix + ]; + } + ]; + }; + + winters = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = nixModules ++ [ + inputs.nixos-hardware.nixosModules.framework-16-inch-7040-amd + ./profiles/winters/nixos.nix + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = mixedModules ++ [ + ./profiles/winters/home.nix + ]; + } + ]; + }; + + nginx = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/server1/nginx/nixos.nix + ]; + }; + + calibre = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/server1/calibre/nixos.nix + ]; + }; + + jellyfin = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + ./profiles/server1/jellyfin/nixos.nix + ]; + }; + + transmission = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/server1/transmission/nixos.nix + ]; + }; + + matrix = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/server1/matrix/nixos.nix + ]; + }; + + sound = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/server1/sound/nixos.nix + ]; + }; + + spotifyd = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/server1/spotifyd/nixos.nix + ]; + }; + + paperless = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/server1/paperless/nixos.nix + ]; + }; + + #ovm swarsel + sync = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/remote/oracle/sync/nixos.nix + ]; + }; + + #ovm swarsel + swatrix = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + inputs.sops-nix.nixosModules.sops + ./profiles/remote/oracle/matrix/nixos.nix + ]; + }; }; - sandbox = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/sandbox/nixos.nix - ]; + # pure Home Manager setups - for non-NixOS machines + # run rebuild using `hmswitch` + + homeConfigurations = { + + "leons@PCisLee" = inputs.home-manager.lib.homeManagerConfiguration { + modules = homeModules ++ mixedModules ++ [ + ./profiles/surface/home.nix + ]; + }; + }; - twoson = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profiles/twoson/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/twoson/home.nix - ]; - } - ]; - }; + nixOnDroidConfigurations = { - threed = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - lanzaboote.nixosModules.lanzaboote - ./profiles/threed/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/threed/home.nix - ]; - } - ]; - }; + default = inputs.nix-on-droid.lib.nixOnDroidConfiguration { + modules = [ + ./profiles/mysticant/configuration.nix + ]; + }; - fourside = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - nixos-hardware.nixosModules.lenovo-thinkpad-p14s-amd-gen2 - ./profiles/fourside/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/fourside/home.nix - ]; - } - ]; - }; - - winters = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - nixos-hardware.nixosModules.framework-16-inch-7040-amd - ./profiles/winters/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/winters/home.nix - ]; - } - ]; - }; - - stand = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = nixModules ++ [ - ./profiles/stand/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.homelen.imports = mixedModules ++ [ - ./profiles/stand/home.nix - ]; - } - ]; - }; - - nginx = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/server1/nginx/nixos.nix - ]; - }; - - calibre = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/server1/calibre/nixos.nix - ]; - }; - - jellyfin = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - # sops-nix.nixosModules.sops - ./profiles/server1/jellyfin/nixos.nix - ]; - }; - - transmission = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/server1/transmission/nixos.nix - ]; - }; - - matrix = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - # this is to import a service module that is not on nixpkgs - # this way avoids infinite recursion errors - modules = [ - sops-nix.nixosModules.sops - ./profiles/server1/matrix/nixos.nix - ]; - }; - - sound = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/server1/sound/nixos.nix - ]; - }; - - spotifyd = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/server1/spotifyd/nixos.nix - ]; - }; - - paperless = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/server1/paperless/nixos.nix - ]; - }; - - #ovm swarsel - sync = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/remote/oracle/sync/nixos.nix - ]; - }; - - #ovm swarsel - swatrix = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs pkgs; }; - modules = [ - sops-nix.nixosModules.sops - ./profiles/remote/oracle/matrix/nixos.nix - ]; - }; - }; - - # pure Home Manager setups - for non-NixOS machines - # run rebuild using `hmswitch` - - homeConfigurations = { - - "leons@PCisLee" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = homeModules ++ mixedModules ++ [ - ./profiles/surface/home.nix - ]; }; }; - - nixOnDroidConfigurations = { - - default = nix-on-droid.lib.nixOnDroidConfiguration { - modules = [ - ./profiles/mysticant/configuration.nix - ]; - }; - - }; - - packages.x86_64-linux = { - - proxmox-lxc = nixos-generators.nixosGenerate { - inherit system; - modules = [ - ./profiles/server1/TEMPLATE/nixos.nix - ]; - format = "proxmox-lxc"; - }; - - }; - - }; } + +

    @@ -9451,7 +9441,7 @@ The standard Emacs behaviour for the Python process shell is a bit annoying. Thi
    -
  • Nix common prefix bracketer
    +
  • Nix common prefix bracketer

    This function searches for common delimiters in region and removes them, summarizing all captured lines by it. @@ -9484,7 +9474,7 @@ This function searches for common delimiters in region and removes them, summari

  • -
  • Nix formatters
    +
  • Nix formatters

    This formats the org code block at point in accordance to the nixpkgs-fmt formatter @@ -11057,8 +11047,8 @@ This adds a rudimentary nix-mode to Emacs. I have not really tried this out, as

  • -
    -

    4.4.3. nixpkgs-fmt

    +
    +

    4.4.3. nixpkgs-fmt

    Adds functions for formatting nix code. @@ -13073,7 +13063,7 @@ My laptop, sadly soon to be replaced by a new one, since most basic functions ar

    Author: Leon Schwarzäugl

    -

    Created: 2024-07-20 Sa 15:47

    +

    Created: 2024-07-21 So 15:56

    Validate

    diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..b9a8554 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,24 @@ +{ inputs, ... }: { + additions = final: _prev: import ../pkgs { pkgs = final; }; + modifications = final: _prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + + # river = prev.river.overrideAttrs (oldAttrs: rec { + # pname = "river"; + # version = "git"; + # src = prev.fetchFromGitHub { + # owner = "riverwm"; + # repo = pname; + # rev = "c16628c7f57c51d50f2d10a96c265fb0afaddb02"; + # hash = "sha256-E3Xtv7JeCmafiNmpuS5VuLgh1TDAbibPtMo6A9Pz6EQ="; + # fetchSubmodules = true; + # }; + # }); + }; + + nixpkgs-stable = final: _prev: { + stable = import inputs.nixpkgs-stable { inherit (final) system; }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..c915eb0 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1 @@ +{ ... }: { } diff --git a/profiles/common/nixos.nix b/profiles/common/nixos.nix index 1a1aa9a..15dc26d 100644 --- a/profiles/common/nixos.nix +++ b/profiles/common/nixos.nix @@ -13,7 +13,7 @@ }; }; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + # nix.settings.experimental-features = ["nix-command" "flakes"]; users.mutableUsers = false;