Skip to content

Commit

Permalink
Create a flake.nix, with a darwinModules output for nix-darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Mar 16, 2024
1 parent 4fccab8 commit 0bdba3d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
25 changes: 25 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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})"
'';
};
};
};
}

0 comments on commit 0bdba3d

Please sign in to comment.