From 4db41c080f066e564f05c251b719ca8834af1c00 Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Tue, 4 Mar 2025 00:14:29 -0600 Subject: [PATCH] add fw13 pickwick compatible hardware module --- flake.lock | 98 +++++++++++++++++++++++++++++++++++++ flake.nix | 95 ++++++++++++++++++++++++++++------- hosts/pickwick/default.nix | 2 + hosts/pickwick/hardware.nix | 4 +- 4 files changed, 179 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index b5364a0..8fd9ae8 100644 --- a/flake.lock +++ b/flake.lock @@ -36,6 +36,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -77,6 +93,49 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1740915799, + "narHash": "sha256-JvQvtaphZNmeeV+IpHgNdiNePsIpHD5U/7QN5AeY44A=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "42b1ba089d2034d910566bf6b40830af6b8ec732", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -117,6 +176,22 @@ "type": "github" } }, + "nixos-hardware": { + "locked": { + "lastModified": 1740646007, + "narHash": "sha256-dMReDQobS3kqoiUCQIYI9c0imPXRZnBubX20yX/G5LE=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "009b764ac98a3602d41fc68072eeec5d24fc0e49", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1739736696, @@ -169,9 +244,12 @@ "inputs": { "disko": "disko", "ghostty": "ghostty", + "git-hooks": "git-hooks", "home-manager": "home-manager", "nix-index-database": "nix-index-database", + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix", "zen-browser": "zen-browser" } }, @@ -190,6 +268,26 @@ "type": "github" } }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1739829690, + "narHash": "sha256-mL1szCeIsjh6Khn3nH2cYtwO5YXG6gBiTw1A30iGeDU=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "3d0579f5cc93436052d94b73925b48973a104204", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "zen-browser": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 608ca64..d391ec8 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; disko.url = "github:nix-community/disko"; disko.inputs.nixpkgs.follows = "nixpkgs"; home-manager.url = "github:nix-community/home-manager"; @@ -12,12 +13,17 @@ ghostty.url = "github:ghostty-org/ghostty"; nix-index-database.url = "github:nix-community/nix-index-database"; nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + git-hooks.url = "github:cachix/git-hooks.nix"; + git-hooks.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, home-manager, + treefmt-nix, ... } @ inputs: let inherit (self) outputs; @@ -44,24 +50,77 @@ }; }; commonArgs = createCommonArgs system; - in import ./hosts commonArgs // { - # nixosConfigurations = { - # pickwick = nixpkgs.lib.nixosSystem { - # specialArgs = {inherit inputs outputs system dots user;}; - # modules = [ - # ./nixos - # # ./nixos/configuration.nix - # ./hosts/pickwick - # inputs.disko.nixosModules.default - # inputs.home-manager.nixosModules.home-manager - # (nixpkgs.lib.mkAliasOptionModule [ "hm" ] [ - # "home-manager" - # "users" - # user - # ]) - # ]; - # }; - # }; + # call with forAllSystems (commonArgs: function body) + forAllSystems = + fn: + lib.genAttrs [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ] (system: fn (createCommonArgs system)); + treefmtEval = forAllSystems ( + { pkgs, ... }: + treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs.nixfmt-rfc-style.enable = true; + settings.global.excludes = [ "flake.lock" ]; + } + ); + in (import ./hosts commonArgs) // + { + checks = forAllSystems ( + { + pkgs, + system, + ... + }: + { + formatting = treefmtEval.${system}.config.build.check self; + pre-commit-check = inputs.git-hooks.lib.${system}.run { + src = ./.; + excludes = [ "flake.lock" ]; + hooks = { + treefmt = { + enable = true; + package = lib.mkForce treefmtEval.${system}.config.build.wrapper; + args = [ + # "--config-file ${treefmtEval.${system}.config.build.configFile}" + ]; + }; + }; + }; + } + ); + + devShells = forAllSystems ( + { + pkgs, + system, + ... + }: + { + default = pkgs.mkShell { + inherit (self.checks.${system}.pre-commit-check) shellHook; + + name = "dotfiles"; + buildInputs = self.checks.${system}.pre-commit-check.enabledPackages; + nativeBuildInputs = [ + treefmtEval.${system}.config.build.wrapper + ]; + packages = with pkgs; [ + sops + age + ssh-to-age + nixfmt-rfc-style + ]; + DIRENV_LOG_FORMAT = ""; + }; + } + ); + + formatter = forAllSystems ({ system, ... }: treefmtEval.${system}.config.build.wrapper); + }; } diff --git a/hosts/pickwick/default.nix b/hosts/pickwick/default.nix index 7ffbea8..518951d 100644 --- a/hosts/pickwick/default.nix +++ b/hosts/pickwick/default.nix @@ -29,6 +29,8 @@ bluetooth.enable = true; }; + services.fwupd.enable = true; + time.timeZone = "America/Chicago"; users.users = { diff --git a/hosts/pickwick/hardware.nix b/hosts/pickwick/hardware.nix index fb8116c..c23cc32 100644 --- a/hosts/pickwick/hardware.nix +++ b/hosts/pickwick/hardware.nix @@ -1,10 +1,11 @@ -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, pkgs, modulesPath, inputs, ... }: { boot.loader.systemd-boot.enable = true; imports = [ (modulesPath + "/installer/scan/not-detected.nix") (import ./disko.nix { device = "/dev/nvme0n1"; }) + inputs.nixos-hardware.nixosModules.framework-13-7040-amd ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "usbhid" "sd_mod" ]; @@ -15,7 +16,6 @@ networking.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - swapDevices = [ {