introduce treefmt-nix
This commit is contained in:
parent
2bc86a4912
commit
200063fcb1
4 changed files with 340 additions and 310 deletions
23
flake.lock
23
flake.lock
|
@ -843,7 +843,8 @@
|
|||
"retiolum": "retiolum",
|
||||
"srvos": "srvos",
|
||||
"stylix": "stylix",
|
||||
"taskshell": "taskshell"
|
||||
"taskshell": "taskshell",
|
||||
"treefmt-nix": "treefmt-nix_3"
|
||||
}
|
||||
},
|
||||
"sops-nix": {
|
||||
|
@ -1029,6 +1030,26 @@
|
|||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix_3": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1724833132,
|
||||
"narHash": "sha256-F4djBvyNRAXGusJiNYInqR6zIMI3rvlp6WiKwsRISos=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "3ffd842a5f50f435d3e603312eefa4790db46af5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
129
flake.nix
129
flake.nix
|
@ -58,6 +58,11 @@
|
|||
|
||||
srvos.url = "github:nix-community/srvos";
|
||||
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
landingpage = {
|
||||
#url = "git+file:///home/palo/dev/landingpage";
|
||||
url = "github:mrVanDalo/landingpage";
|
||||
|
@ -91,28 +96,30 @@
|
|||
};
|
||||
|
||||
outputs =
|
||||
inputs@{ self
|
||||
, clan-core
|
||||
, clan-fact-generators
|
||||
, flake-parts
|
||||
, home-manager
|
||||
, home-manager-utils
|
||||
, kmonad
|
||||
, landingpage
|
||||
, nixos-anywhere
|
||||
, nixos-hardware
|
||||
, nixpkgs
|
||||
, nixpkgs-legacy_2211
|
||||
, nixpkgs-legacy_2311
|
||||
, nixpkgs-legacy_2405
|
||||
, nixpkgs-unstable-small
|
||||
, permown
|
||||
, polygon-art
|
||||
, private_assets
|
||||
, retiolum
|
||||
, srvos
|
||||
, stylix
|
||||
, taskshell
|
||||
inputs@{
|
||||
self,
|
||||
clan-core,
|
||||
clan-fact-generators,
|
||||
flake-parts,
|
||||
home-manager,
|
||||
home-manager-utils,
|
||||
kmonad,
|
||||
landingpage,
|
||||
nixos-anywhere,
|
||||
nixos-hardware,
|
||||
nixpkgs,
|
||||
nixpkgs-legacy_2211,
|
||||
nixpkgs-legacy_2311,
|
||||
nixpkgs-legacy_2405,
|
||||
nixpkgs-unstable-small,
|
||||
permown,
|
||||
polygon-art,
|
||||
private_assets,
|
||||
retiolum,
|
||||
srvos,
|
||||
stylix,
|
||||
taskshell,
|
||||
treefmt-nix,
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -165,7 +172,10 @@
|
|||
inherit inputs;
|
||||
assets = ./assets;
|
||||
factsGenerator = clan-fact-generators.lib { inherit pkgs; };
|
||||
clanLib = import ./lib/clanlib.nix { inherit (pkgs) lib; machineDir = ./machines; };
|
||||
clanLib = import ./lib/clanlib.nix {
|
||||
inherit (pkgs) lib;
|
||||
machineDir = ./machines;
|
||||
};
|
||||
zerotierDeviceName = "ztbn67ogn2";
|
||||
components = ./components;
|
||||
features = ./features;
|
||||
|
@ -173,30 +183,36 @@
|
|||
};
|
||||
|
||||
clanSetup =
|
||||
{ name
|
||||
, host
|
||||
, modules
|
||||
}: {
|
||||
{
|
||||
name,
|
||||
host,
|
||||
modules,
|
||||
}:
|
||||
{
|
||||
|
||||
clan.core.networking.targetHost = lib.mkDefault "root@${host}";
|
||||
nixpkgs.pkgs = meta.pkgs;
|
||||
nixpkgs.hostPlatform = meta.system;
|
||||
clan.core.facts.secretStore = "password-store";
|
||||
|
||||
imports = modules ++ defaultModules ++ [
|
||||
imports =
|
||||
modules
|
||||
++ defaultModules
|
||||
++ [
|
||||
./machines/${name}/configuration.nix
|
||||
];
|
||||
};
|
||||
|
||||
zerotierControllerModule =
|
||||
{
|
||||
zerotierControllerModule = {
|
||||
clan.core.networking.zerotier.controller = {
|
||||
enable = true;
|
||||
public = false;
|
||||
};
|
||||
};
|
||||
|
||||
zerotierModules = { pkgs, ... }: {
|
||||
zerotierModules =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
|
||||
# this magically adds all my machines in the zero tier network
|
||||
|
@ -231,7 +247,9 @@
|
|||
_module.args.inputs = self.inputs;
|
||||
}
|
||||
# ssh keys
|
||||
({ config, ... }: {
|
||||
(
|
||||
{ config, ... }:
|
||||
{
|
||||
users.users.root.openssh.authorizedKeys.keyFiles = [
|
||||
# master key
|
||||
./assets/mrvandalo_rsa.pub
|
||||
|
@ -239,7 +257,8 @@
|
|||
"${config.clan.core.clanDir}/machines/chungus/facts/ssh.syncoid.id_ed25519.pub"
|
||||
"${config.clan.core.clanDir}/machines/chungus/facts/ssh.rbackup.id_ed25519.pub"
|
||||
];
|
||||
})
|
||||
}
|
||||
)
|
||||
{
|
||||
# disable emergency mode everywhere, although it might be needed on laptops
|
||||
boot.initrd.systemd.emergencyAccess = false;
|
||||
|
@ -250,11 +269,20 @@
|
|||
systemd.enableEmergencyMode = false;
|
||||
}
|
||||
# configure nix
|
||||
({ pkgs, lib, clanLib, ... }:
|
||||
(
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
clanLib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
nix.settings.substituters = [ "http://cache.orbi.wg0" ];
|
||||
nix.settings.trusted-public-keys = [ (clanLib.readFact "nix-serve.pub" "orbi") ];
|
||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||
nix.settings.experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
nix.settings.max-jobs = 1;
|
||||
# no channesl needed this way
|
||||
nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
|
||||
|
@ -282,7 +310,8 @@
|
|||
boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10;
|
||||
boot.loader.generic-extlinux-compatible.configurationLimit = lib.mkDefault 10;
|
||||
boot.loader.grub.configurationLimit = lib.mkDefault 10;
|
||||
})
|
||||
}
|
||||
)
|
||||
# My Structure
|
||||
./components
|
||||
./features
|
||||
|
@ -293,15 +322,20 @@
|
|||
permown.nixosModules.permown
|
||||
kmonad.nixosModules.default
|
||||
# some default things I always want
|
||||
({ pkgs, ... }: {
|
||||
(
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
boot.tmp.useTmpfs = lib.mkDefault true;
|
||||
environment.systemPackages = [
|
||||
pkgs.nixpkgs-fmt
|
||||
];
|
||||
})
|
||||
}
|
||||
)
|
||||
];
|
||||
|
||||
stylixModules = { pkgs, config, ... }: {
|
||||
stylixModules =
|
||||
{ pkgs, config, ... }:
|
||||
{
|
||||
imports = [ stylix.nixosModules.stylix ];
|
||||
stylix.enable = true;
|
||||
stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-light-medium.yaml";
|
||||
|
@ -327,7 +361,9 @@
|
|||
};
|
||||
};
|
||||
|
||||
homeManagerModules = { pkgs, config, ... }: {
|
||||
homeManagerModules =
|
||||
{ pkgs, config, ... }:
|
||||
{
|
||||
imports = [
|
||||
home-manager.nixosModules.home-manager
|
||||
];
|
||||
|
@ -345,7 +381,9 @@
|
|||
|
||||
in
|
||||
|
||||
flake-parts.lib.mkFlake { inherit inputs; } ({ self, pkgs, ... }: {
|
||||
flake-parts.lib.mkFlake { inherit inputs; } (
|
||||
{ self, pkgs, ... }:
|
||||
{
|
||||
# We define our own systems below. you can still use this to add system specific outputs to your flake.
|
||||
# See: https://flake.parts/getting-started
|
||||
systems = [ "x86_64-linux" ];
|
||||
|
@ -353,9 +391,12 @@
|
|||
# import clan-core modules
|
||||
imports = [
|
||||
clan-core.flakeModules.default
|
||||
./nix/formatter.nix
|
||||
];
|
||||
|
||||
perSystem = { pkgs, ... }: {
|
||||
perSystem =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
packages.pkl = pkgs.callPackage ./pkgs/pkl { };
|
||||
};
|
||||
|
||||
|
@ -496,7 +537,7 @@
|
|||
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
16
nix/formatter.nix
Normal file
16
nix/formatter.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{ inputs, ... }:
|
||||
{
|
||||
imports = [ inputs.treefmt-nix.flakeModule ];
|
||||
|
||||
perSystem = _: {
|
||||
treefmt = {
|
||||
projectRootFile = ".git/config";
|
||||
programs.nixfmt.enable = true;
|
||||
programs.terraform.enable = true;
|
||||
programs.hclfmt.enable = true;
|
||||
programs.jsonfmt.enable = true;
|
||||
programs.yamlfmt.enable = true;
|
||||
programs.black.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
48
treefmt.toml
48
treefmt.toml
|
@ -1,48 +0,0 @@
|
|||
# One CLI to format the code tree - https://github.com/numtide/treefmt
|
||||
|
||||
[formatter.nix]
|
||||
command = "nixpkgs-fmt"
|
||||
includes = [ "*.nix"]
|
||||
|
||||
[formatter.shell]
|
||||
command = "shfmt"
|
||||
options = [
|
||||
"-i",
|
||||
"2", # indent 2
|
||||
"-s", # simplify the code
|
||||
"-w", # write back to the file
|
||||
]
|
||||
includes = ["*.sh"]
|
||||
excludes = ["scripts/hetzner-dedicated-wipe-and-install-nixos.sh"]
|
||||
|
||||
#[formatter.shellcheck]
|
||||
#command = "shellcheck"
|
||||
#includes = ["*.sh"]
|
||||
#excludes = ["./scripts/hetzner-dedicated-wipe-and-install-nixos.sh"]
|
||||
|
||||
[formatter.python]
|
||||
command = "black"
|
||||
includes = ["*.py"]
|
||||
|
||||
[formatter.media]
|
||||
command = "prettier"
|
||||
options = ["--write"]
|
||||
includes = [
|
||||
"*.json",
|
||||
"*.md",
|
||||
"*.yaml",
|
||||
"*.yml",
|
||||
]
|
||||
|
||||
[formatter.terragrunt]
|
||||
command = "terragrunt"
|
||||
options = [ "hclfmt" ]
|
||||
includes = [ "*.hcl" ]
|
||||
excludes = [ "*/.terraform" ]
|
||||
|
||||
[formatter.terraform]
|
||||
command = "terraform"
|
||||
options = [ "fmt" ]
|
||||
includes = [ "*.tf" ]
|
||||
excludes = [ "*/.terraform" ]
|
||||
|
Loading…
Reference in a new issue