NixOS configuration ๐Ÿช„

๐ŸŽจ nix fmt now formats ++ added nix check

Signed-off-by: Xaiya Schumin <d.schumin@proton.me>

+33 -18
+1
.envrc
··· 1 + #!/usr/bin/env bash 1 2 if has nix_direnv_version; then 2 3 watch_file modules/flake/shell.nix 3 4
+2 -4
.tangled/workflows/format.yaml
··· 2 2 3 3 when: 4 4 - event: ["push", "manual"] 5 - branch: ["main"] 6 5 - event: ["pull_request"] 7 - branch: ["main"] 8 6 9 7 steps: 10 8 - name: "Enter development environment" 11 9 command: "nix develop ." 12 - - name: "check code (with nix fmt)" 13 - command: "nix fmt" 10 + - name: "run through nix checks" 11 + command: "nix check"
-1
home/default.nix
··· 1 1 { 2 - lib, 3 2 self, 4 3 inputs, 5 4 ...
+5
modules/flake/checks/default.nix
··· 1 + { 2 + imports = [ 3 + ./formatting.nix # Checks if the formatting was right with treefmt 4 + ]; 5 + }
+14
modules/flake/checks/formatting.nix
··· 1 + { self, ... }: 2 + { 3 + perSystem = 4 + { pkgs, config, ... }: 5 + { 6 + checks.formatting = 7 + pkgs.runCommandLocal "formatting-checks" { nativeBuildInputs = [ config.formatter ]; } 8 + '' 9 + cd ${self} 10 + treefmt --no-cache --fail-on-change 11 + touch $out 12 + ''; 13 + }; 14 + }
+1
modules/flake/default.nix
··· 3 3 ../../systems 4 4 5 5 ./lib # The library used by our configuration 6 + ./checks # tests and checks from our configuration 6 7 ./shell # Shell environment for this configuration 7 8 8 9 ./args.nix # Arguments given to this flake
+7 -13
modules/flake/shell/formatter.nix
··· 3 3 perSystem = 4 4 { pkgs, ... }: 5 5 { 6 - # The nix formatter checks the files instead of formating them 7 - # The formatter is put into a workflow at .tangled/workflows/format.yaml 8 - 9 6 formatter = pkgs.treefmt.withConfig { 10 7 runtimeInputs = with pkgs; [ 11 8 nixfmt # nix formating tool ··· 18 15 19 16 # useful script for statix commands to work 20 17 # https://github.com/isabelroses/dotfiles/blob/23c7db61455348653703d32ffdc2135fd045f6b8/modules/flake/programs/formatter.nix#L22C1-L26C14 21 - (writeShellScriptBin "statix-check" '' 18 + (writeShellScriptBin "statix-fix" '' 22 19 for file in "$@"; do 23 - ${lib.getExe statix} check "$file" 20 + ${lib.getExe statix} fix "$file" 24 21 done 25 22 '') 26 23 ]; ··· 37 34 formatter = { 38 35 nixfmt = { 39 36 command = "nixfmt"; 40 - options = "-c"; # Check files instead of formating 41 - 42 37 includes = [ "*.nix" ]; 43 38 }; 44 39 ··· 46 41 command = "deadnix"; 47 42 48 43 # Warn if there was any dead nix files 49 - options = [ "--fail" ]; 44 + options = [ "--edit" ]; 50 45 includes = [ "*.nix" ]; 51 46 }; 52 47 53 48 statix = { 54 - command = "statix-check"; 49 + command = "statix-fix"; 55 50 includes = [ "*.nix" ]; 56 51 }; 57 52 ··· 70 65 command = "shfmt"; 71 66 options = [ 72 67 "-s" # simplify the code 73 - "-d" # error out of the changes 68 + "-w" # write changes if found changes 74 69 "-i" 75 70 "2" # indent files for 2 spaces 76 71 ]; ··· 85 80 86 81 taplo = { 87 82 command = "taplo"; 88 - options = "error"; 83 + options = "format"; 89 84 includes = [ "*.toml" ]; 90 85 }; 91 86 92 87 yamlfmt = { 93 88 command = "yamlfmt"; 94 89 options = [ 95 - "-dry" 96 - "-continue_on_error" 90 + "-formatter" 97 91 ]; 98 92 99 93 includes = [
+3
modules/home/default.nix
··· 1 + { 2 + 3 + }