From f5730508de4c75b8f6e80c3289c0f5797c5a0e49 Mon Sep 17 00:00:00 2001 From: jalr Date: Sun, 7 Nov 2021 13:38:02 +0000 Subject: [PATCH] Use flakes --- .editorconfig | 15 ++++ .envrc | 1 + .gitignore | 3 +- flake.lock | 68 +++++++++++++++++++ flake.nix | 64 +++++++++++++++++ machines/cadmium/hardware-configuration.nix | 8 +-- machines/default.nix | 11 +++ machines/hafnium/hardware-configuration.nix | 6 +- machines/jalr-t520/hardware-configuration.nix | 8 +-- 9 files changed, 172 insertions(+), 12 deletions(-) create mode 100644 .editorconfig create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 machines/default.nix diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..243442f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 +indent_style = space +indent_size = 4 + +[*.{yaml,yml}] +indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index ce3dce1..d4347e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/configuration.nix +result* +.pre-commit-config.yaml diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..24ccece --- /dev/null +++ b/flake.lock @@ -0,0 +1,68 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nix-pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1634595438, + "narHash": "sha256-hV9D41fqTateTligwNd9dmJKQ0R0w6RpCN92xR3LhHk=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "06fa80325b6fe3b28d136071dd0ce55d4817e9fd", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "master", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1636138231, + "narHash": "sha256-FZQ5wBcB9zI21uQMB/PaEQ/cLYk+Bwnig5cg1+2rPgg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5c02380de3951d0237807c16eb19873cb3c5f75d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nix-pre-commit-hooks": "nix-pre-commit-hooks", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1f46d00 --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05"; + + nix-pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix/master"; + inputs.flake-utils.follows = "flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + outputs = + { self + , nixpkgs + , flake-utils + , nix-pre-commit-hooks + , ... + }@inputs: flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { inherit system; }; + inherit (pkgs) lib; + in + { + checks = { + pre-commit-check = nix-pre-commit-hooks.lib.${system}.run { + src = self; + hooks = { + black.enable = true; + nixpkgs-fmt.enable = true; + shellcheck.enable = true; + }; + }; + }; + devShell = pkgs.mkShell { + buildInputs = (with pkgs; [ + black + nixpkgs-fmt + shellcheck + ]); + + shellHook = '' + ${self.checks.${system}.pre-commit-check.shellHook} + ''; + }; + }) // { + nixosConfigurations = nixpkgs.lib.mapAttrs + (hostname: { system + , extraModules ? [ ] + , nixpkgs ? inputs.nixpkgs + }: nixpkgs.lib.nixosSystem rec { + inherit system; + + modules = [ + (./machines + "/${hostname}/configuration.nix") + + { + _module.args.inputs = inputs; + } + ] ++ extraModules; + }) + (import ./machines inputs); + }; +} diff --git a/machines/cadmium/hardware-configuration.nix b/machines/cadmium/hardware-configuration.nix index 028d500..9dfe46f 100644 --- a/machines/cadmium/hardware-configuration.nix +++ b/machines/cadmium/hardware-configuration.nix @@ -1,9 +1,9 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, modulesPath, ... }: { - imports = - [ - ]; + imports = [ + "${modulesPath}/installer/scan/not-detected.nix" + ]; boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sr_mod" ]; boot.initrd.kernelModules = [ "dm-snapshot" ]; diff --git a/machines/default.nix b/machines/default.nix new file mode 100644 index 0000000..c8c86f8 --- /dev/null +++ b/machines/default.nix @@ -0,0 +1,11 @@ +inputs: { + jalr-t520 = { + system = "x86_64-linux"; + }; + cadmium = { + system = "x86_64-linux"; + }; + hafnium = { + system = "x86_64-linux"; + }; +} diff --git a/machines/hafnium/hardware-configuration.nix b/machines/hafnium/hardware-configuration.nix index 3078b93..7f5e39c 100644 --- a/machines/hafnium/hardware-configuration.nix +++ b/machines/hafnium/hardware-configuration.nix @@ -1,9 +1,9 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + "${modulesPath}/installer/scan/not-detected.nix" + ]; boot.initrd.availableKernelModules = [ "nvme" "ehci_pci" "xhci_pci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.kernelModules = [ ]; diff --git a/machines/jalr-t520/hardware-configuration.nix b/machines/jalr-t520/hardware-configuration.nix index 051b2d3..4b9a1b0 100644 --- a/machines/jalr-t520/hardware-configuration.nix +++ b/machines/jalr-t520/hardware-configuration.nix @@ -1,9 +1,9 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, modulesPath, ... }: { - imports = - [ - ]; + imports = [ + "${modulesPath}/installer/scan/not-detected.nix" + ]; boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "firewire_ohci" "usb_storage" "usbhid" "sd_mod" "sdhci_pci" ]; boot.initrd.kernelModules = [ "dm-snapshot" ];