diff --git a/.gitignore b/.gitignore index e0e98f6..a047594 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .terraform* +.direnv +.pre-commit-config.yaml terraform.tfstate* config.tf.json diff --git a/flake.lock b/flake.lock index 096daad..2a5f535 100644 --- a/flake.lock +++ b/flake.lock @@ -45,23 +45,19 @@ "type": "github" } }, - "disko": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, + "flake-compat": { + "flake": false, "locked": { - "lastModified": 1726396892, - "narHash": "sha256-KRGuT5nGRAOT3heigRWg41tbYpTpapGhsWc+XjnIx0w=", - "owner": "nix-community", - "repo": "disko", - "rev": "51e3a7e51279fedfb6669a00d21dc5936c78a6ce", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { - "owner": "nix-community", - "repo": "disko", + "owner": "edolstra", + "repo": "flake-compat", "type": "github" } }, @@ -85,39 +81,45 @@ "type": "github" } }, - "home-manager": { + "gitignore": { "inputs": { "nixpkgs": [ - "agenix", + "pre-commit-hooks", "nixpkgs" ] }, "locked": { - "lastModified": 1703113217, - "narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1", + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { - "owner": "nix-community", - "repo": "home-manager", + "owner": "hercules-ci", + "repo": "gitignore.nix", "type": "github" } }, - "impermanence": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "agenix", + "nixpkgs" + ] + }, "locked": { - "lastModified": 1725690722, - "narHash": "sha256-4qWg9sNh5g1qPGO6d/GV2ktY+eDikkBTbWSg5/iD2nY=", + "lastModified": 1703113217, + "narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=", "owner": "nix-community", - "repo": "impermanence", - "rev": "63f4d0443e32b0dd7189001ee1894066765d18a5", + "repo": "home-manager", + "rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1", "type": "github" }, "original": { "owner": "nix-community", - "repo": "impermanence", + "repo": "home-manager", "type": "github" } }, @@ -137,13 +139,51 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1725513492, + "narHash": "sha256-tyMUA6NgJSvvQuzB7A1Sf8+0XCHyfSPRx/b00o6K0uo=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "7570de7b9b504cfe92025dd1be797bf546f66528", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "agenix": "agenix", - "disko": "disko", "flake-parts": "flake-parts", - "impermanence": "impermanence", "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", "srvos": "srvos" } }, diff --git a/flake.nix b/flake.nix index 2fca73b..60cc363 100644 --- a/flake.nix +++ b/flake.nix @@ -9,9 +9,11 @@ imports = [ ./hosts ./modules + ./pre-commit-hooks.nix ]; perSystem = { + config, pkgs, system, inputs', @@ -30,6 +32,9 @@ pkgs.sops inputs'.agenix.packages.agenix ]; + shellHook = '' + ${config.pre-commit.installationScript} + ''; }; }; }; @@ -40,20 +45,18 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - disko = { - url = "github:nix-community/disko"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - impermanence.url = "github:nix-community/impermanence"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + srvos = { url = "github:numtide/srvos"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/hosts/germanium/hardware-configuration.nix b/hosts/germanium/hardware-configuration.nix index f69ecbf..ae74336 100644 --- a/hosts/germanium/hardware-configuration.nix +++ b/hosts/germanium/hardware-configuration.nix @@ -1,24 +1,28 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - { - imports = - [ (modulesPath + "/profiles/qemu-guest.nix") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.initrd.availableKernelModules = ["ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod"]; + boot.initrd.kernelModules = []; + boot.kernelModules = []; + boot.extraModulePackages = []; - fileSystems."/" = - { device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; - swapDevices = [ ]; + swapDevices = []; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/pre-commit-hooks.nix b/pre-commit-hooks.nix new file mode 100644 index 0000000..3cd9b9c --- /dev/null +++ b/pre-commit-hooks.nix @@ -0,0 +1,9 @@ +{inputs, ...}: { + imports = [inputs.pre-commit-hooks.flakeModule]; + + perSystem.pre-commit = { + settings.excludes = ["flake.lock"]; + + settings.hooks.alejandra.enable = true; + }; +}