summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2023-10-07 10:10:55 -0400
committerseth <[email protected]>2023-10-07 10:18:46 -0400
commit519191cd9f31d1fe1c205535ddc4efe5f2e63793 (patch)
tree441a3b0cbf33a15ac052a1fd6a6894cf169f493b /flake.nix
parent62a26a94a11774b7c14ea10cde0ca2294990fb9b (diff)
treewide!: remove flake-parts
while i love flake parts, i want to keep dependencies for this project as small as possible
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix76
1 files changed, 52 insertions, 24 deletions
diff --git a/flake.nix b/flake.nix
index 23ad382..67942bd 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,30 +6,58 @@
extra-trusted-public-keys = ["cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="];
};
- inputs = {
- nixpkgs.url = "nixpkgs/nixos-unstable";
+ inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
- parts = {
- url = "github:hercules-ci/flake-parts";
- inputs.nixpkgs-lib.follows = "nixpkgs";
- };
- };
+ outputs = {
+ nixpkgs,
+ self,
+ ...
+ }: let
+ inherit (nixpkgs) lib;
+
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ forAllSystems = fn: lib.genAttrs systems (sys: fn nixpkgs.legacyPackages.${sys});
+ in {
+ packages = forAllSystems (
+ pkgs: let
+ overlay = lib.fix (final: self.overlays.default final pkgs);
+
+ /*
+ this filters out packages that may be broken or not supported
+ on the current system. packages that have no `version` or `platforms`
+ meta attribute are assumed to be valid
+ */
+ isValid = _: v:
+ lib.elem pkgs.system (v.meta.platforms or [pkgs.system]) && !(v.meta.broken or false);
- outputs = {parts, ...} @ inputs:
- parts.lib.mkFlake {inherit inputs;} {
- imports = [
- ./pkgs
- ./modules
- ./templates
- ];
-
- systems = [
- "x86_64-linux"
- "aarch64-linux"
- "x86_64-darwin"
- "aarch64-darwin"
- ];
-
- perSystem = {pkgs, ...}: {formatter = pkgs.alejandra;};
- };
+ pkgs' = lib.filterAttrs isValid overlay;
+ in
+ pkgs' // {default = pkgs'.treefetch;}
+ );
+
+ overlays.default = final: prev: (import ./pkgs final prev);
+
+ templates = let
+ # string -> string -> {}
+ mkTemplate = name: description: {
+ path = builtins.path {
+ path = ./templates/${name};
+ name = "${name}-template";
+ };
+
+ inherit description;
+ };
+ in
+ lib.mapAttrs mkTemplate {
+ basic = "minimal boilerplate for my flakes";
+ full = "big template for complex flakes (using flake-parts)";
+ nixos = "minimal boilerplate for flake-based nixos configuration";
+ };
+ };
}