From e850329a8e7767f04fd7e45e8aa4b337f7038020 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Tue, 22 Oct 2024 11:56:48 +0200 Subject: [PATCH] flake: move away from flake-parts (remove unnecessary abstractions) --- flake.lock | 62 ++++++------------------------------ flake.nix | 73 ++++++++++++++----------------------------- hosts/default.nix | 76 ++++++++++++++++++++++----------------------- modules/default.nix | 4 +-- treefmt.nix | 12 ++++--- 5 files changed, 80 insertions(+), 147 deletions(-) diff --git a/flake.lock b/flake.lock index 54a77a7..e474b9e 100644 --- a/flake.lock +++ b/flake.lock @@ -156,26 +156,6 @@ } }, "flake-parts_2": { - "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1727826117, - "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "lanzaboote", @@ -196,7 +176,7 @@ "type": "github" } }, - "flake-parts_4": { + "flake-parts_3": { "inputs": { "nixpkgs-lib": "nixpkgs-lib_2" }, @@ -214,7 +194,7 @@ "type": "github" } }, - "flake-parts_5": { + "flake-parts_4": { "inputs": { "nixpkgs-lib": "nixpkgs-lib_3" }, @@ -262,26 +242,6 @@ } }, "flake-utils_2": { - "inputs": { - "systems": [ - "systems" - ] - }, - "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_3": { "inputs": { "systems": "systems_2" }, @@ -299,7 +259,7 @@ "type": "github" } }, - "flake-utils_4": { + "flake-utils_3": { "inputs": { "systems": "systems_3" }, @@ -317,7 +277,7 @@ "type": "github" } }, - "flake-utils_5": { + "flake-utils_4": { "inputs": { "systems": "systems_6" }, @@ -458,8 +418,8 @@ "inputs": { "crane": "crane", "flake-compat": "flake-compat_2", - "flake-parts": "flake-parts_3", - "flake-utils": "flake-utils_3", + "flake-parts": "flake-parts_2", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixpkgs" ], @@ -563,7 +523,7 @@ }, "niri": { "inputs": { - "flake-parts": "flake-parts_4", + "flake-parts": "flake-parts_3", "niri-stable": "niri-stable", "niri-unstable": "niri-unstable", "nixpkgs": "nixpkgs_4", @@ -870,8 +830,8 @@ }, "nvf": { "inputs": { - "flake-parts": "flake-parts_5", - "flake-utils": "flake-utils_4", + "flake-parts": "flake-parts_4", + "flake-utils": "flake-utils_3", "mnw": "mnw", "nil": "nil", "nixpkgs": "nixpkgs_6", @@ -2687,8 +2647,6 @@ "basix": "basix", "chaotic": "chaotic", "firefox-addons": "firefox-addons", - "flake-parts": "flake-parts_2", - "flake-utils": "flake-utils_2", "home-manager": "home-manager_2", "lanzaboote": "lanzaboote", "niri": "niri", @@ -2899,7 +2857,7 @@ }, "wezterm": { "inputs": { - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils_4", "freetype2": "freetype2", "harfbuzz": "harfbuzz", "libpng": "libpng", diff --git a/flake.nix b/flake.nix index c3722fb..f1d5fae 100644 --- a/flake.nix +++ b/flake.nix @@ -1,85 +1,58 @@ { description = "nezia's nixos configuration"; - outputs = inputs: - inputs.flake-parts.lib.mkFlake {inherit inputs;} { - systems = ["x86_64-linux"]; - - imports = [ - ./hosts - ./modules - ]; - - perSystem = {pkgs, ...}: { - devShells.default = pkgs.mkShell { - packages = [ - pkgs.alejandra - pkgs.git - ]; - }; - formatter = pkgs.alejandra; + outputs = { + self, + nixpkgs, + systems, + treefmt-nix, + ... + } @ inputs: let + eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system}); + treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix); + in { + devShells = eachSystem (pkgs: { + default = pkgs.mkShell { + packages = [ + pkgs.alejandra + pkgs.git + ]; }; - }; - + }); + formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); + nixosModules = import ./modules; + nixosConfigurations = import ./hosts {inherit self inputs;}; + }; inputs = { - # global, so they can be `.follow`ed systems.url = "github:nix-systems/default-linux"; - - flake-utils = { - url = "github:numtide/flake-utils"; - inputs.systems.follows = "systems"; - }; - - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable"; - firefox-addons = { url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; inputs.nixpkgs.follows = "nixpkgs"; }; - home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - wezterm = { url = "github:wez/wezterm/main?dir=nix"; inputs.nixpkgs.follows = "nixpkgs"; }; - - nvf = { - url = "github:notashelf/nvf"; - }; - + nvf = {url = "github:notashelf/nvf";}; basix.url = "github:notashelf/basix"; - plasma-manager = { url = "github:nix-community/plasma-manager"; inputs.nixpkgs.follows = "nixpkgs"; inputs.home-manager.follows = "home-manager"; }; - ags.url = "github:Aylur/ags"; - - niri = { - url = "github:sodiboo/niri-flake"; - }; - + niri = {url = "github:sodiboo/niri-flake";}; lanzaboote = { url = "github:nix-community/lanzaboote/v0.4.1"; - - # Optional but recommended to limit the size of your system closure. inputs.nixpkgs.follows = "nixpkgs"; }; - treefmt-nix.url = "github:numtide/treefmt-nix"; - nixos-hardware.url = "github:NixOS/nixos-hardware"; }; } diff --git a/hosts/default.nix b/hosts/default.nix index c473472..152f4de 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -2,48 +2,48 @@ self, inputs, ... -}: { - flake.nixosConfigurations = let - inherit (inputs.nixpkgs.lib) nixosSystem; - specialArgs = { - inherit inputs self; - }; - in { - vamos = nixosSystem { - inherit specialArgs; - modules = [ - ./vamos +}: let + inherit (inputs.nixpkgs.lib) nixosSystem; + specialArgs = { + inherit inputs self; + }; +in { + vamos = nixosSystem { + system = "x86_64-linux"; + inherit specialArgs; + modules = [ + ./vamos - self.nixosModules.style + self.nixosModules.style - ({pkgs, ...}: { - style = let - wallpaper = pkgs.fetchurl { - url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/e0cf0eb237dc5baba86661a3572b20a6183c1876/wallpapers/nix-wallpaper-nineish-catppuccin-frappe.png?raw=true"; - hash = "sha256-/HAtpGwLxjNfJvX5/4YZfM8jPNStaM3gisK8+ImRmQ4="; - }; - in { - gtk.enable = true; - inherit wallpaper; + ({pkgs, ...}: { + style = let + wallpaper = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/e0cf0eb237dc5baba86661a3572b20a6183c1876/wallpapers/nix-wallpaper-nineish-catppuccin-frappe.png?raw=true"; + hash = "sha256-/HAtpGwLxjNfJvX5/4YZfM8jPNStaM3gisK8+ImRmQ4="; }; - }) + in { + gtk.enable = true; + inherit wallpaper; + }; + }) - inputs.nixos-hardware.nixosModules.framework-13-7040-amd - ]; - }; + inputs.nixos-hardware.nixosModules.framework-13-7040-amd + ]; + }; - solaire = nixosSystem { - inherit specialArgs; - modules = [ - ./solaire - self.nixosModules.style - { - style = { - gtk.enable = false; - wallpaper = ../wallpapers/lucy-edgerunners-wallpaper.jpg; - }; - } - ]; - }; + solaire = nixosSystem { + system = "x86_64-linux"; + inherit specialArgs; + modules = [ + ./solaire + self.nixosModules.style + { + style = { + gtk.enable = false; + wallpaper = ../wallpapers/lucy-edgerunners-wallpaper.jpg; + }; + } + ]; }; } diff --git a/modules/default.nix b/modules/default.nix index 4d8324f..5f7031f 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,5 +1,3 @@ { - flake.nixosModules = { - style = import ./style; - }; + style = import ./style; } diff --git a/treefmt.nix b/treefmt.nix index ee530a0..ac1e542 100644 --- a/treefmt.nix +++ b/treefmt.nix @@ -1,6 +1,10 @@ -# TODO: maybe use flake-parts -{...}: { - # Used to find the project root +{pkgs, ...}: { projectRootFile = "flake.nix"; - programs.alejandra.enable = true; + programs = { + alejandra.enable = true; + prettier = { + enable = true; + package = pkgs.prettierd; + }; + }; }