···11+{ inputs, ... }:
22+{
33+ # This flake, currently just uses pure nixOS systems
44+ # set the system flake output here
55+ systems = [ "x86_64-linux" ];
66+77+ perSystem =
88+ { system, ... }:
99+ {
1010+ # control how packages are built within the flake
1111+ _module.args.pkgs = import inputs.nixpkgs {
1212+ inherit system;
1313+1414+ config.allowUnfree = true;
1515+ overlays = [ ];
1616+ };
1717+ };
1818+}
+4-1
modules/flake/default.nix
···33 ../../systems
4455 ./lib # The library used by our configuration
66+ ./shell # Shell environment for this configuration
77+88+ ./args.nix # Arguments given to this flake
69 ];
77-}1010+}
+2-4
modules/flake/lib/default.nix
···11-{
22- ...
33-}: {
11+_: {
42 # TODO: add more based on need
55-}33+}
+29
modules/flake/shell/default.nix
···11+{
22+ # include the formatter for this configuration
33+ imports = [ ./formatter.nix ];
44+55+ perSystem =
66+ {
77+ pkgs,
88+ inputs',
99+ config,
1010+ ...
1111+ }:
1212+ {
1313+ devShells.default = pkgs.mkShellNoCC {
1414+ name = "dotfiles";
1515+ meta.description = "development environment for this flake";
1616+1717+ inputsFrom = [ config.formatter ];
1818+1919+ DIRENV_LOG_FORMAT = "";
2020+2121+ packages = [
2222+ pkgs.gitMinimal # git is needed for flake based configurations
2323+ inputs'.agenix-rekey.packages.default # manging secrets
2424+ config.formatter # nix formatter
2525+ pkgs.nix-output-monitor # detailed diff view between generations
2626+ ];
2727+ };
2828+ };
2929+}
+108
modules/flake/shell/formatter.nix
···11+{ lib, ... }:
22+{
33+ perSystem =
44+ { pkgs, ... }:
55+ {
66+ # The nix formatter checks the files instead of formating them
77+ # The formatter is put into a workflow at .tangled/workflows/format.yaml
88+99+ formatter = pkgs.treefmt.withConfig {
1010+ runtimeInputs = with pkgs; [
1111+ nixfmt # nix formating tool
1212+ deadnix # find and remove unused nix files
1313+ statix # Lints and suggestions for the nix programming language
1414+ shellcheck # shell script analysis tool
1515+ shfmt # format .sh files
1616+ taplo # TOML toolkit
1717+ yamlfmt # format .yaml or yml files
1818+1919+ # useful script for statix commands to work
2020+ # https://github.com/isabelroses/dotfiles/blob/23c7db61455348653703d32ffdc2135fd045f6b8/modules/flake/programs/formatter.nix#L22C1-L26C14
2121+ (writeShellScriptBin "statix-check" ''
2222+ for file in "$@"; do
2323+ ${lib.getExe statix} check "$file"
2424+ done
2525+ '')
2626+ ];
2727+2828+ settings = {
2929+ on-unmatched = "info";
3030+ tree-root-file = "flake.nix";
3131+3232+ excludes = [
3333+ "secrets/*"
3434+ "assets/*"
3535+ ];
3636+3737+ formatter = {
3838+ nixfmt = {
3939+ command = "nixfmt";
4040+ options = "-c"; # Check files instead of formating
4141+4242+ includes = [ "*.nix" ];
4343+ };
4444+4545+ deadnix = {
4646+ command = "deadnix";
4747+4848+ # Warn if there was any dead nix files
4949+ options = [ "--fail" ];
5050+ includes = [ "*.nix" ];
5151+ };
5252+5353+ statix = {
5454+ command = "statix-check";
5555+ includes = [ "*.nix" ];
5656+ };
5757+5858+ shellcheck = {
5959+ command = "shellcheck";
6060+6161+ includes = [
6262+ "*.sh"
6363+ "*.bash"
6464+ "*.envrc"
6565+ "*.envrc.*"
6666+ ];
6767+ };
6868+6969+ shfmt = {
7070+ command = "shfmt";
7171+ options = [
7272+ "-s" # simplify the code
7373+ "-d" # error out of the changes
7474+ "-i"
7575+ "2" # indent files for 2 spaces
7676+ ];
7777+7878+ includes = [
7979+ "*.sh"
8080+ "*.bash"
8181+ "*.envrc"
8282+ "*.envrc.*"
8383+ ];
8484+ };
8585+8686+ taplo = {
8787+ command = "taplo";
8888+ options = "error";
8989+ includes = [ "*.toml" ];
9090+ };
9191+9292+ yamlfmt = {
9393+ command = "yamlfmt";
9494+ options = [
9595+ "-dry"
9696+ "-continue_on_error"
9797+ ];
9898+9999+ includes = [
100100+ "*.yml"
101101+ "*.yaml"
102102+ ];
103103+ };
104104+ };
105105+ };
106106+ };
107107+ };
108108+}