diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..af0cc93 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +use flake diff --git a/.gitignore b/.gitignore index 7dc3520..48ce75d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ result result-* - +.direnv +.rumdl_cache diff --git a/default.nix b/default.nix index 7eafa2b..7139b95 100644 --- a/default.nix +++ b/default.nix @@ -5,24 +5,32 @@ # Having pkgs default to is fine though, and it lets you use short # commands such as: # nix-build -A mypackage -{pkgs ? import {}}: { - # The `lib`, `modules`, and `overlays` names are special - lib = import ./lib {inherit pkgs;}; # functions - modules = import ./modules; # NixOS modules - overlays = import ./overlays; # nixpkgs overlays - hmModules = import ./hm-modules; # Home Manager modules. +{pkgs ? import {}, ...}: let + inherit (pkgs) lib; - yaziPlugins = pkgs.lib.recurseIntoAttrs (pkgs.callPackage ./pkgs/yazi/plugins {}); + normalizePackage = v: + if lib.isDerivation v + then v + else if builtins.isAttrs v && v ? default && lib.isDerivation v.default + then v.default + else v; - rust-mcp-server = pkgs.callPackage ./pkgs/rust-mcp-server {}; - modular-mcp = pkgs.callPackage ./pkgs/modular-mcp {}; + discoveredPackages = lib.filesystem.packagesFromDirectoryRecursive { + inherit (pkgs) callPackage newScope; + directory = ./pkgs; + }; - bibata-modern-cursors-classic = pkgs.callPackage ./pkgs/bibata-modern-cursors-classic {}; - bibata-modern-cursors-classic-hyprcursor = pkgs.callPackage ./pkgs/bibata-modern-cursors-classic-hyprcursor {}; + allPackages = lib.filterAttrs (_: lib.isDerivation) ( + lib.mapAttrs (_: normalizePackage) discoveredPackages + ); +in + { + # The `lib`, `modules`, and `overlays` names are special + lib = import ./lib {inherit pkgs;}; # functions + modules = import ./modules; # NixOS modules + overlays = import ./overlays; # nixpkgs overlays + hmModules = import ./hm-modules; # Home Manager modules. - bibata-modern-cursors-rosepine = pkgs.callPackage ./pkgs/bibata-modern-cursors-rosepine {}; - bibata-modern-cursors-rosepine-hyprcursor = pkgs.callPackage ./pkgs/bibata-modern-cursors-rosepine-hyprcursor {}; - - bibata-modern-cursors-gruvbox-dark = pkgs.callPackage ./pkgs/bibata-modern-cursors-gruvbox-dark {}; - bibata-modern-cursors-gruvbox-dark-hyprcursor = pkgs.callPackage ./pkgs/bibata-modern-cursors-gruvbox-dark-hyprcursor {}; -} + yaziPlugins = lib.recurseIntoAttrs (pkgs.callPackage ./pkgs/yazi/plugins {}); + } + // allPackages diff --git a/flake.lock b/flake.lock index 885e6e1..57288ad 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,54 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "import-tree": { + "locked": { + "lastModified": 1763762820, + "narHash": "sha256-ZvYKbFib3AEwiNMLsejb/CWs/OL/srFQ8AogkebEPF0=", + "owner": "vic", + "repo": "import-tree", + "rev": "3c23749d8013ec6daa1d7255057590e9ca726646", + "type": "github" + }, + "original": { + "owner": "vic", + "repo": "import-tree", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1770843696, @@ -16,12 +65,46 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "root": { "inputs": { + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "import-tree": "import-tree", "nixpkgs": "nixpkgs", + "systems": "systems", "treefmt-nix": "treefmt-nix" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index ce12ee2..16b81d5 100644 --- a/flake.nix +++ b/flake.nix @@ -1,44 +1,29 @@ { description = "My personal NUR repository"; + inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + flake-parts.url = "github:hercules-ci/flake-parts"; + import-tree.url = "github:vic/import-tree"; + systems.url = "github:nix-systems/default"; + treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; - }; - outputs = { - self, - nixpkgs, - treefmt-nix, - }: let - forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; - treefmtEval = forAllSystems ( - system: let - pkgs = import nixpkgs {inherit system;}; - in - treefmt-nix.lib.evalModule pkgs ./treefmt.nix - ); - in { - legacyPackages = forAllSystems ( - system: - import ./default.nix { - pkgs = import nixpkgs {inherit system;}; - } - ); - packages = forAllSystems ( - system: let - legacy = self.legacyPackages.${system}; - topLevel = nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) legacy; - yaziPlugins = nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) legacy.yaziPlugins; - in - topLevel // {inherit yaziPlugins;} - ); - - formatter = forAllSystems (system: treefmtEval.${system}.config.build.wrapper); - checks = forAllSystems (system: { - formatting = treefmtEval.${system}.config.build.check self; - }); + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; }; + + outputs = inputs: + inputs.flake-parts.lib.mkFlake {inherit inputs;} { + imports = [ + inputs.treefmt-nix.flakeModule + (inputs.import-tree ./parts) + ]; + }; } diff --git a/lib/default.nix b/lib/default.nix index 3626ea4..5e5502a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,5 +1,4 @@ -{pkgs}: -with pkgs.lib; { +_: { # Add your library functions here # # hexint = x: hexvals.${toLower x}; diff --git a/parts/devshell.nix b/parts/devshell.nix new file mode 100644 index 0000000..304c71a --- /dev/null +++ b/parts/devshell.nix @@ -0,0 +1,7 @@ +{ + perSystem = {pkgs, ...}: { + devShells.default = pkgs.mkShell { + packages = [pkgs.tokei]; + }; + }; +} diff --git a/parts/packages.nix b/parts/packages.nix new file mode 100644 index 0000000..e3a6b57 --- /dev/null +++ b/parts/packages.nix @@ -0,0 +1,10 @@ +{ + perSystem = {pkgs, ...}: let + inherit (pkgs) lib; + legacy = import ../default.nix {inherit pkgs;}; + packages = lib.filterAttrs (_: lib.isDerivation) legacy; + in { + legacyPackages = legacy; + inherit packages; + }; +} diff --git a/parts/systems.nix b/parts/systems.nix new file mode 100644 index 0000000..41df61b --- /dev/null +++ b/parts/systems.nix @@ -0,0 +1,3 @@ +{inputs, ...}: { + systems = import inputs.systems; +} diff --git a/parts/treefmt.nix b/parts/treefmt.nix new file mode 100644 index 0000000..82966e7 --- /dev/null +++ b/parts/treefmt.nix @@ -0,0 +1,11 @@ +_: { + perSystem.treefmt.programs = { + alejandra.enable = true; + nixf-diagnose.enable = true; + deadnix.enable = true; + statix.enable = true; + + rumdl-check.enable = true; + rumdl-format.enable = true; + }; +} diff --git a/pkgs/qq-jfryy/default.nix b/pkgs/qq-jfryy/default.nix new file mode 100644 index 0000000..ce1067d --- /dev/null +++ b/pkgs/qq-jfryy/default.nix @@ -0,0 +1,28 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, +}: +buildGoModule rec { + pname = "qq-jfryy"; + version = "0.3.3"; + + src = fetchFromGitHub { + owner = "JFryy"; + repo = "qq"; + rev = "v${version}"; + hash = "sha256-Ukk9PWlTKQ1S9LbGJtvrrKxXqYZDIdYkrs6f2vFJcZs="; + }; + + vendorHash = "sha256-dTC9Nk1zixv/9jG+xUGC7Yoc8FFlY7wio9FLoUQO7RA="; + + ldflags = ["-s" "-w"]; + + meta = { + description = "jq-compatible multi-format configuration transcoder"; + homepage = "https://github.com/JFryy/qq"; + license = lib.licenses.mit; + mainProgram = "qq"; + platforms = lib.platforms.unix; + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..9f61c6a --- /dev/null +++ b/shell.nix @@ -0,0 +1,11 @@ +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + nodeName = lock.nodes.root.inputs.flake-compat; + flakeCompat = fetchTarball { + url = + lock.nodes.${nodeName}.locked.url + or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz"; + sha256 = lock.nodes.${nodeName}.locked.narHash; + }; +in + (import flakeCompat {src = ./.;}).shellNix diff --git a/treefmt.nix b/treefmt.nix deleted file mode 100644 index 71f8d4a..0000000 --- a/treefmt.nix +++ /dev/null @@ -1,9 +0,0 @@ -_: { - programs = { - alejandra.enable = true; - deadnix.enable = true; - statix.enable = true; - - mdformat.enable = true; - }; -}