Skip to content

Commit

Permalink
Merge pull request #6 from grahamc/flake
Browse files Browse the repository at this point in the history
Create / publish a flake with a nix-darwin module
  • Loading branch information
zimbatm committed Mar 18, 2024
2 parents 4fccab8 + f3609c9 commit aeec72b
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/flakehub-publish-rolling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Publish every Git push to master to FlakeHub"
on:
push:
branches:
- "master"
jobs:
flakehub-publish:
runs-on: "ubuntu-latest"
permissions:
id-token: "write"
contents: "read"
steps:
- uses: "actions/checkout@v3"
- uses: "DeterminateSystems/nix-installer-action@main"
- uses: "DeterminateSystems/flakehub-push@main"
with:
name: "zimbatm/h"
rolling: true
visibility: "public"
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 = nixpkgs.legacyPackages.${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 aeec72b

Please sign in to comment.