diff --git a/.github/workflows/flake-checks.yaml b/.github/workflows/flake-checks.yaml index af58897..e965c8a 100644 --- a/.github/workflows/flake-checks.yaml +++ b/.github/workflows/flake-checks.yaml @@ -14,7 +14,9 @@ jobs: - name: Install Nix uses: DeterminateSystems/nix-installer-action@v3 - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Check for dead code + - name: Check for dead code in .nix files run: git ls-files '*.nix' | nix run nixpkgs#deadnix - - name: Check for lints + - name: Check for lints in .nix files run: nix run nixpkgs#statix -- check + - name: Check formatting in .nix files + run: git ls-files '*.nix' | xargs nix run nixpkgs#alejandra -- --check diff --git a/SwarselSystems.org b/SwarselSystems.org index db906a3..c77f6f6 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -5131,6 +5131,11 @@ Programming languages and default lsp's are defined here: [[#h:0e7e8bea-ec58-499 nmap lsof + # nix + alejandra + deadnix + statix + # local file sharing wormhole-rs @@ -7524,41 +7529,37 @@ Used in: [[#h:bbcfa895-4d46-4b1d-b84e-f634e982c46e][Centered org-mode Buffers]] #+end_src -**** org-mode: Auto-tangle and export Configuration Files +**** org-mode: Upon-save actions (Auto-tangle, export to html, formatting) :PROPERTIES: :CUSTOM_ID: h:59d4306e-9b73-4b2c-b039-6a6518c357fc :END: -This section automatically tangles all configuration blocks in this file to the defined Emacs org-file. It also exports the configuration file as html. +This section handles everything that shoudld happen when I save =SwarselSystems.org=. It: +1) automatically tangles all configuration blocks in this file +2) exports the configuration file as html for an easier reading experience with working links and index +3) formats the generated =.nix= files in accordance to the =Alejandra=-style. +We set a hook that runs everytime we save the file. It would be a bit more efficient to only export and format when we enter a magit window for instance (since especially the html export takes times), however, since I cannot be sure to only ever commit from magit (I do indeed sometimes use git from the command line), I prefer this approach. #+begin_src emacs-lisp - - (defun swarsel/org-babel-tangle-config () - (when (string-equal (buffer-file-name) - swarsel-swarsel-org-filepath) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-html-export-to-html) - (org-babel-tangle))) - (when (string-equal (buffer-file-name) - swarsel-emacs-org-filepath) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-html-export-to-html) - (org-babel-tangle))) - (when (string-equal (buffer-file-name) - swarsel-nix-org-filepath) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - - (setq org-html-htmlize-output-type nil) - - (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'swarsel/org-babel-tangle-config))) - - + (defun run-alejandra () + (interactive) + (let ((default-directory (expand-file-name "~/.dotfiles"))) + (shell-command "alejandra . -q"))) + + (defun swarsel/org-babel-tangle-config () + (when (string-equal (buffer-file-name) + swarsel-swarsel-org-filepath) + ;; Dynamic scoping to the rescue + (let ((org-confirm-babel-evaluate nil)) + (org-html-export-to-html) + (org-babel-tangle) + (run-alejandra)))) + + (setq org-html-htmlize-output-type nil) + + (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'swarsel/org-babel-tangle-config))) #+end_src diff --git a/flake.nix b/flake.nix index 2632648..df2dcdb 100644 --- a/flake.nix +++ b/flake.nix @@ -2,76 +2,73 @@ description = "SwarseFlake - Nix Flake for all SwarselSystems"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05"; - + # user-level configuration home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - + # overlay to access bleeding edge emacs emacs-overlay = { url = "github:nix-community/emacs-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; - + # nix user repository # i use this mainly to not have to build all firefox extensions # myself as well as for the emacs-init package (tbd) nur.url = "github:nix-community/NUR"; - + # provides GL to non-NixOS hosts nixgl.url = "github:guibou/nixGL"; - + # manages all theming using Home-Manager stylix.url = "github:danth/stylix"; - + # nix secrets management sops-nix.url = "github:Mic92/sops-nix"; - + # enable secure boot on NixOS lanzaboote.url = "github:nix-community/lanzaboote"; - + # nix for android nix-on-droid = { url = "github:t184256/nix-on-droid/release-23.05"; inputs.nixpkgs.follows = "nixpkgs"; }; - + # generate NixOS images nixos-generators = { url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs"; }; - + # patches for gaming on nix nix-gaming = { url = "github:fufexan/nix-gaming"; }; - + # hardware quirks on nix nixos-hardware = { url = "github:NixOS/nixos-hardware/master"; }; - + # dynamic library loading nix-alien = { url = "github:thiagokokada/nix-alien"; }; - + # automatic nintendo switch payload injection nswitch-rcm-nix = { url = "github:Swarsel/nswitch-rcm-nix"; }; - }; - outputs = inputs@{ - + outputs = inputs @ { nixpkgs, nixpkgs-stable, home-manager, @@ -85,49 +82,54 @@ nixos-hardware, nix-alien, nswitch-rcm-nix, - ... }: 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; - }; - + 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; + }; + # 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; - }) - ]; - + 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 = [ stylix.homeManagerModules.stylix - ]; + homeModules = [ + stylix.homeManagerModules.stylix + ]; # Home-Manager modules wanted on both NixOS and non-NixOS systems - mixedModules = [ sops-nix.homeManagerModules.sops - ./profiles/common/home.nix - ]; - + mixedModules = [ + sops-nix.homeManagerModules.sops + ./profiles/common/home.nix + ]; 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` @@ -136,130 +138,153 @@ # 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 ++ [ - ./profiles/onett/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/onett/home.nix - ]; - } - ]; + specialArgs = {inherit inputs pkgs;}; + modules = + nixModules + ++ [ + ./profiles/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 pkgs;}; modules = [ 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 - ]; - } - ]; + 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; }; - modules = nixModules ++ [ - lanzaboote.nixosModules.lanzaboote - ./profiles/threed/nixos.nix - home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = mixedModules ++ [ - ./profiles/threed/home.nix - ]; - } - ]; + 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 + ]; + } + ]; }; - + 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 - ]; - } - ]; + 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 - ]; - } - ]; + 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 - ]; - } - ]; + 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 pkgs;}; modules = [ sops-nix.nixosModules.sops ./profiles/server1/nginx/nixos.nix ]; }; - + calibre = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + specialArgs = {inherit inputs pkgs;}; modules = [ sops-nix.nixosModules.sops ./profiles/server1/calibre/nixos.nix ]; }; - + jellyfin = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + specialArgs = {inherit inputs pkgs;}; modules = [ # sops-nix.nixosModules.sops ./profiles/server1/jellyfin/nixos.nix ]; }; - + transmission = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + specialArgs = {inherit inputs pkgs;}; modules = [ sops-nix.nixosModules.sops ./profiles/server1/transmission/nixos.nix ]; }; - + matrix = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + specialArgs = {inherit inputs pkgs;}; # this is to import a service module that is not on nixpkgs # this way avoids infinite recursion errors modules = [ @@ -267,43 +292,43 @@ ./profiles/server1/matrix/nixos.nix ]; }; - + sound = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + specialArgs = {inherit inputs pkgs;}; modules = [ sops-nix.nixosModules.sops ./profiles/server1/sound/nixos.nix ]; }; - + spotifyd = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + specialArgs = {inherit inputs pkgs;}; modules = [ sops-nix.nixosModules.sops ./profiles/server1/spotifyd/nixos.nix ]; }; - + paperless = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + specialArgs = {inherit inputs pkgs;}; modules = [ sops-nix.nixosModules.sops ./profiles/server1/paperless/nixos.nix ]; }; - + #ovm swarsel sync = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs pkgs; }; + 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; }; + specialArgs = {inherit inputs pkgs;}; modules = [ sops-nix.nixosModules.sops ./profiles/remote/oracle/matrix/nixos.nix @@ -315,29 +340,26 @@ # run rebuild using `hmswitch` homeConfigurations = { - "leons@PCisLee" = home-manager.lib.homeManagerConfiguration { inherit pkgs; - modules = homeModules ++ mixedModules ++ [ - ./profiles/surface/home.nix - ]; + modules = + homeModules + ++ mixedModules + ++ [ + ./profiles/surface/home.nix + ]; }; - }; nixOnDroidConfigurations = { - default = nix-on-droid.lib.nixOnDroidConfiguration { modules = [ ./profiles/mysticant/configuration.nix ]; }; - }; packages.x86_64-linux = { - }; - }; } diff --git a/index.html b/index.html index b1ab052..90ff89c 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- +-This file has 40971 words spanning 10908 lines and was last revised on 2024-07-19 00:29:02 +0200. +This file has 41033 words spanning 10909 lines and was last revised on 2024-07-19 00:52:31 +0200.
@@ -437,7 +437,7 @@
-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-19 00:29:02 +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-19 00:52:31 +0200)
@@ -6335,6 +6335,11 @@
-This section automatically tangles all configuration blocks in this file to the defined Emacs org-file. It also exports the configuration file as html.
+This section handles everything that shoudld happen when I save SwarselSystems.org
. It:
.nix
files in accordance to the Alejandra
-style.+We set a hook that runs everytime we save the file. It would be a bit more efficient to only export and format when we enter a magit window for instance (since especially the html export takes times), however, since I cannot be sure to only ever commit from magit (I do indeed sometimes use git from the command line), I prefer this approach. +
-(defun swarsel/org-babel-tangle-config () - (when (string-equal (buffer-file-name) - swarsel-swarsel-org-filepath) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-html-export-to-html) - (org-babel-tangle))) - (when (string-equal (buffer-file-name) - swarsel-emacs-org-filepath) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-html-export-to-html) - (org-babel-tangle))) - (when (string-equal (buffer-file-name) - swarsel-nix-org-filepath) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - -(setq org-html-htmlize-output-type nil) +(defun run-alejandra () + (interactive) + (let ((default-directory (expand-file-name "~/.dotfiles"))) + (shell-command "alejandra . -q"))) -(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'swarsel/org-babel-tangle-config))) + (defun swarsel/org-babel-tangle-config () + (when (string-equal (buffer-file-name) + swarsel-swarsel-org-filepath) + ;; Dynamic scoping to the rescue + (let ((org-confirm-babel-evaluate nil)) + (org-html-export-to-html) + (org-babel-tangle) + (run-alejandra)))) + (setq org-html-htmlize-output-type nil) + (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'swarsel/org-babel-tangle-config)))
This function searches for common delimiters in region and removes them, summarizing all captured lines by it. @@ -12907,7 +12912,7 @@