From 0bdba3d5044c66b601ec2745af7c41819198c632 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sat, 16 Mar 2024 15:50:38 -0400 Subject: [PATCH] Create a flake.nix, with a darwinModules output for nix-darwin --- flake.lock | 25 +++++++++++++++++++++++++ flake.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c49975d --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1710451336, + "narHash": "sha256-pP86Pcfu3BrAvRO7R64x7hs+GaQrjFes+mEPowCfkxY=", + "rev": "d691274a972b3165335d261cc4671335f5c67de9", + "revCount": 596954, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.596954%2Brev-d691274a972b3165335d261cc4671335f5c67de9/018e4219-154b-7a41-b00a-47c7351cce9c/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.0" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..70b6386 --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "faster shell navigation of projects"; + + inputs = { + nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0"; + }; + + outputs = { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + inherit system; + pkgs = import nixpkgs { inherit system; }; + }); + in + { + packages = forEachSupportedSystem ({ pkgs, ... }: { + default = import ./default.nix { inherit pkgs; }; + }); + + darwinModules.default = { lib, config, pkgs, ... }: + let + h = self.packages.${pkgs.stdenv.system}.default; + in + { + options = { + programs.h.codeRoot = lib.mkOption { + type = lib.types.str; + default = "~/src"; + description = lib.mdDoc '' + Root location for checking out your code. + ''; + }; + }; + config = { + environment.systemPackages = [ h ]; + + environment.extraInit = '' + eval "$(${h}/bin/h --setup ${lib.escapeShellArg config.programs.h.codeRoot})" + ''; + }; + }; + }; +}