summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix2
-rw-r--r--flake.lock23
-rw-r--r--flake.nix71
-rw-r--r--templates/default.nix13
-rw-r--r--treefmt.nix11
5 files changed, 40 insertions, 80 deletions
diff --git a/default.nix b/default.nix
index 94e4cf4..25178be 100644
--- a/default.nix
+++ b/default.nix
@@ -7,7 +7,6 @@ in
overlays = [ ];
inherit system;
},
- lib ? pkgs.lib,
nixpkgs ? (
fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.nixpkgs.locked.rev}.tar.gz";
@@ -17,6 +16,7 @@ in
system ? builtins.currentSystem,
}:
let
+ inherit (pkgs) lib;
packageDirectory = ./pkgs;
scope = lib.makeScope pkgs.newScope (
diff --git a/flake.lock b/flake.lock
index 809940f..0793da5 100644
--- a/flake.lock
+++ b/flake.lock
@@ -18,28 +18,7 @@
},
"root": {
"inputs": {
- "nixpkgs": "nixpkgs",
- "treefmt-nix": "treefmt-nix"
- }
- },
- "treefmt-nix": {
- "inputs": {
- "nixpkgs": [
- "nixpkgs"
- ]
- },
- "locked": {
- "lastModified": 1727984844,
- "narHash": "sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc=",
- "owner": "numtide",
- "repo": "treefmt-nix",
- "rev": "4446c7a6fc0775df028c5a3f6727945ba8400e64",
- "type": "github"
- },
- "original": {
- "owner": "numtide",
- "repo": "treefmt-nix",
- "type": "github"
+ "nixpkgs": "nixpkgs"
}
}
},
diff --git a/flake.nix b/flake.nix
index d52fceb..41d61a1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,39 +6,41 @@
extra-trusted-public-keys = [ "getchoo.cachix.org-1:ftdbAUJVNaFonM0obRGgR5+nUmdLMM+AOvDOSx0z5tE=" ];
};
- inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
-
- # this can be removed with `inputs.treefmt-nix.follows = ""`
- treefmt-nix = {
- url = "github:numtide/treefmt-nix";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- };
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{
self,
nixpkgs,
- treefmt-nix,
}:
let
inherit (nixpkgs) lib;
- systems = [
- "x86_64-linux"
- "aarch64-linux"
- "x86_64-darwin"
- "aarch64-darwin"
- ];
+
+ # Support all systems exported by Nixpkgs
+ systems = lib.systems.flakeExposed;
+ # But separate our primarily supported systems
+ tier1Systems = with lib.platforms; lib.intersectLists (aarch64 ++ aarch64) (darwin ++ linux);
forAllSystems = lib.genAttrs systems;
- nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
- treefmtFor = forAllSystems (system: treefmt-nix.lib.evalModule nixpkgsFor.${system} ./treefmt.nix);
+ forTier1Systems = lib.genAttrs tier1Systems;
+ nixpkgsFor = nixpkgs.legacyPackages;
in
{
- checks = forAllSystems (system: {
- treefmt = treefmtFor.${system}.config.build.check self;
- });
+ checks = forTier1Systems (
+ system:
+ let
+ pkgs = nixpkgsFor.${system};
+
+ mkCheck =
+ name: deps: script:
+ pkgs.runCommand name { nativeBuildInputs = deps; } script;
+ in
+ {
+ deadnix = mkCheck "check-deadnix" [ pkgs.deadnix ] "deadnix --fail ${self}";
+ nixfmt = mkCheck "check-nixfmt" [ pkgs.nixfmt-rfc-style ] "nixfmt --check ${self}";
+ statix = mkCheck "check-statix" [ pkgs.statix ] "statix check ${self}";
+ }
+ );
packages = forAllSystems (
system:
@@ -46,21 +48,24 @@
pkgs = nixpkgsFor.${system};
isAvailable = lib.meta.availableOn { inherit system; };
-
- pkgs' = lib.filterAttrs (lib.const isAvailable) (
- import ./. {
- inherit system;
- inherit nixpkgs;
- inherit pkgs;
- inherit (pkgs) lib;
- }
- );
+ pkgs' = lib.filterAttrs (lib.const isAvailable) (import ./default.nix { inherit pkgs; });
in
- pkgs' // { default = pkgs'.treefetch; }
+ pkgs' // { default = pkgs'.treefetch or pkgs.emptyFile; }
);
- formatter = forAllSystems (system: treefmtFor.${system}.config.build.wrapper);
+ formatter = forTier1Systems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
- templates = import ./templates self;
+ templates =
+ let
+ toTemplate = name: description: {
+ path = ./templates + "/${name}";
+ inherit description;
+ };
+ in
+ lib.mapAttrs toTemplate {
+ basic = "Minimal boilerplate for my Flakes";
+ full = "Big template for complex Flakes (using flake-parts)";
+ nixos = "minimal boilerplate for a Flake-based NixOS configuration";
+ };
};
}
diff --git a/templates/default.nix b/templates/default.nix
deleted file mode 100644
index 62f535e..0000000
--- a/templates/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-self:
-let
- # string -> string -> {}
- toTemplate = name: description: {
- path = self + "/templates/" + name;
- inherit description;
- };
-in
-builtins.mapAttrs toTemplate {
- basic = "minimal boilerplate for my flakes";
- full = "big template for complex flakes (using flake-parts)";
- nixos = "minimal boilerplate for flake-based nixos configuration";
-}
diff --git a/treefmt.nix b/treefmt.nix
deleted file mode 100644
index 2b523c5..0000000
--- a/treefmt.nix
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- projectRootFile = ".git/config";
-
- # TODO: add actionlint
- # https://github.com/numtide/treefmt-nix/pull/146
- programs = {
- deadnix.enable = true;
- nixfmt.enable = true;
- statix.enable = true;
- };
-}