summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2024-01-24 01:56:28 -0500
committerseth <[email protected]>2024-01-24 05:35:36 -0500
commit4967396702ad723d86a8d6792052cfdcad090ccf (patch)
treea80f6184f3396b68e420c601e48d51b9027a8ec8
parentf91cb79249520f21b3ab5bc254607e00760179f9 (diff)
tree-wide: better support legacy nix
-rw-r--r--default.nix26
-rw-r--r--flake.nix26
-rw-r--r--overlay.nix43
-rw-r--r--pkgs/default.nix54
-rw-r--r--templates/default.nix16
5 files changed, 85 insertions, 80 deletions
diff --git a/default.nix b/default.nix
index cb09ef8..8e74c61 100644
--- a/default.nix
+++ b/default.nix
@@ -1,6 +1,20 @@
-(import
- (fetchTarball {
- url = "https://github.com/edolstra/flake-compat/archive/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9.tar.gz";
- sha256 = "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=";
- }) {src = ./.;})
-.defaultNix
+let
+ lock = builtins.fromJSON (builtins.readFile ./flake.lock);
+ nixpkgs' = fetchTarball {
+ url = lock.nodes.nixpkgs.locked.url or "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.nixpkgs.locked.rev}.tar.gz";
+ sha256 = lock.nodes.nixpkgs.locked.narHash;
+ };
+in
+ {
+ nixpkgs ?
+ import nixpkgs' {
+ config = {};
+ overlays = [];
+ inherit system;
+ },
+ system ? builtins.currentSystem,
+ }: let
+ # fixed point wizardry
+ pkgs' = import ./overlay.nix (nixpkgs // pkgs') nixpkgs;
+ in
+ pkgs'
diff --git a/flake.nix b/flake.nix
index 9cd5074..a66c833 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,8 +31,6 @@
system,
...
}: 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 `broken` or `platforms`
@@ -41,30 +39,18 @@
isValid = _: v:
lib.elem pkgs.system (v.meta.platforms or [pkgs.system]) && !(v.meta.broken or false);
- pkgs' = lib.filterAttrs isValid overlay;
+ pkgs' = lib.filterAttrs isValid (import ./. {
+ nixpkgs = pkgs;
+ inherit system;
+ });
in
pkgs' // {default = pkgs'.treefetch;}
);
formatter = forAllSystems (pkgs: pkgs.alejandra);
- overlays.default = final: prev: (import ./pkgs final prev);
-
- templates = let
- # string -> string -> {}
- toTemplate = name: description: {
- path = builtins.path {
- path = ./templates/${name};
- name = "${name}-template";
- };
+ overlays.default = final: prev: import ./overlay.nix final prev;
- 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";
- };
+ templates = import ./templates;
};
}
diff --git a/overlay.nix b/overlay.nix
new file mode 100644
index 0000000..c4adcfb
--- /dev/null
+++ b/overlay.nix
@@ -0,0 +1,43 @@
+final: prev: let
+ inherit (prev) lib callPackage;
+in
+ lib.attrsets.mergeAttrsList [
+ # files/directories are mapped to packages here for convenience sake
+ (
+ let
+ toPkg = name: _:
+ lib.nameValuePair (lib.removeSuffix ".nix" name) (prev.callPackage ./pkgs/${name} {});
+ in
+ lib.mapAttrs' toPkg (builtins.readDir ./pkgs)
+ )
+
+ {
+ clang-tidy-sarif = callPackage ./pkgs/clang-tidy-sarif.nix {inherit (final) clang-tidy-sarif;};
+ clippy-sarif = callPackage ./pkgs/clippy-sarif.nix {inherit (final) clippy-sarif;};
+ hadolint-sarif = callPackage ./pkgs/hadolint-sarif.nix {inherit (final) hadolint-sarif;};
+ sarif-fmt = callPackage ./pkgs/sarif-fmt.nix {inherit (final) sarif-fmt;};
+ shellcheck-sarif = callPackage ./pkgs/shellcheck-sarif.nix {inherit (final) shellcheck-sarif;};
+
+ klassy = prev.libsForQt5.callPackage ./pkgs/klassy.nix {};
+
+ modrinth-app-unwrapped = callPackage ./pkgs/modrinth-app {
+ inherit (final.nodePackages) pnpm;
+
+ inherit
+ (final.darwin.apple_sdk.frameworks)
+ AppKit
+ CoreServices
+ Security
+ WebKit
+ ;
+ };
+
+ modrinth-app = callPackage ./pkgs/modrinth-app/wrapper.nix {
+ inherit (final) modrinth-app-unwrapped;
+ };
+ }
+
+ (lib.optionalAttrs (prev.stdenv.hostPlatform.system == "x86_64-linux") {
+ tcmalloc-tf2 = prev.gperftools.override {inherit (final.pkgsi686Linux.llvmPackages_16) stdenv;};
+ })
+ ]
diff --git a/pkgs/default.nix b/pkgs/default.nix
deleted file mode 100644
index 4713d6c..0000000
--- a/pkgs/default.nix
+++ /dev/null
@@ -1,54 +0,0 @@
-final: prev:
-with prev; let
- # files/directories are mapped to packages here for convenience sake
- imported = lib.pipe ./. [
- builtins.readDir
-
- (
- lib.filterAttrs (
- name: _: !(lib.hasPrefix "_" name) && name != "default.nix"
- )
- )
-
- (
- lib.mapAttrs' (
- file: _: lib.nameValuePair (lib.removeSuffix ".nix" file) (callPackage ./${file} {})
- )
- )
- ];
-
- recursiveMerge = builtins.foldl' (acc: attr: acc // attr) {};
-in
- recursiveMerge [
- imported
-
- {
- clang-tidy-sarif = callPackage ./clang-tidy-sarif.nix {inherit (final) clang-tidy-sarif;};
- clippy-sarif = callPackage ./clippy-sarif.nix {inherit (final) clippy-sarif;};
- hadolint-sarif = callPackage ./hadolint-sarif.nix {inherit (final) hadolint-sarif;};
- sarif-fmt = callPackage ./sarif-fmt.nix {inherit (final) sarif-fmt;};
- shellcheck-sarif = callPackage ./shellcheck-sarif.nix {inherit (final) shellcheck-sarif;};
-
- klassy = libsForQt5.callPackage ./klassy.nix {};
-
- modrinth-app-unwrapped = callPackage ./modrinth-app {
- inherit (final.nodePackages or prev.nodePackages) pnpm;
-
- inherit
- ((final.darwin or prev.darwin).apple_sdk.frameworks)
- AppKit
- CoreServices
- Security
- WebKit
- ;
- };
-
- modrinth-app = callPackage ./modrinth-app/wrapper.nix {
- inherit (final) modrinth-app-unwrapped;
- };
- }
-
- (lib.optionalAttrs (stdenv.hostPlatform.system == "x86_64-linux") {
- tcmalloc-tf2 = gperftools.override {inherit (pkgsi686Linux.llvmPackages_16) stdenv;};
- })
- ]
diff --git a/templates/default.nix b/templates/default.nix
new file mode 100644
index 0000000..349f9df
--- /dev/null
+++ b/templates/default.nix
@@ -0,0 +1,16 @@
+let
+ # string -> string -> {}
+ toTemplate = name: description: {
+ path = builtins.path {
+ path = ./${name};
+ name = "${name}-template";
+ };
+
+ 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";
+ }