tooling: Provide a Nix Flake

This commit is contained in:
Calum MacRae 2021-04-08 21:44:36 +01:00
parent 43e526e3ce
commit ee4bac9dc1
No known key found for this signature in database
GPG key ID: 53922D7E54A14F5D
6 changed files with 128 additions and 5 deletions

View file

@ -17,15 +17,23 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch history
run: git fetch --prune --unshallow
with:
# Flakes don't work on shallow clones
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Nix
uses: cachix/install-nix-action@v12
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20210207_fd6eaa1/install
- name: Enable Flakes
run: echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf
- name: Build
id: build-bin
run: |
@ -39,6 +47,10 @@ jobs:
run: |
echo "::set-output name=version::$(./bin/spacebar --version | cut -d- -f2)"
- name: Build with Nix
run: |
nix build
- name: Get the current tag name
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
@ -48,7 +60,7 @@ jobs:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
[[ "$RELEASE_VERSION" == ${{ steps.check-bin.outputs.version }} ]]
- name: Create Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: create-release

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/bin
/archive
/.idea
result

View file

@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Default to "Solid" style of Font Awesome 5 Free icon font
- Option to display spaces for all displays, including: optional separator, secondary & tertiary space indicator colours in relation to display
- Option to specify only drawing one bar on the main display or multiple bars, one for each display (this aligns with yabai's `external_bar` option)
- Provide a [Nix Flake](https://nixos.wiki/wiki/Flakes)
## [1.2.1](https://github.com/cmacrae/spacebar/releases/tag/v1.2.1) - 2020-11-18

View file

@ -44,6 +44,27 @@ brew services start spacebar
### Nix
A package is generally available to Nix users on macOS in the various channels.
A [Flake](https://nixos.wiki/wiki/Flakes) is also available in this repository and can be used like so:
```nix
{
inputs.darwin.url = "github:lnl7/nix-darwin";
inputs.spacebar.url = "github:cmacrae/spacebar";
outputs = { self, darwin, spacebar }: {
darwinConfigurations.example = darwin.lib.darwinSystem {
modules = [
{
nixpkgs.overlays = [
spacebar.overlay
];
}
];
};
};
}
```
Or try it out with `nix run github:cmacrae/spacebar`!
spacebar can be configured and managed in a declarative manner using the `services.spacebar` module in [nix-darwin](https://github.com/LnL7/nix-darwin)
### Accessibility Permissions
@ -178,7 +199,8 @@ brew upgrade spacebar
brew services start spacebar
```
If you're using the Nix package and keeping your channels up to date, package upgrades will roll in as you command.
If you're using the Nix package form the nixpkgs collection and keeping your channels up to date, package upgrades will roll in as you command.
If you're using the Nix Flake, you can update your `input.spacebar.url` to point to the latest release tag and update your lockfile.
## Requirements and Caveats
Please read the below requirements carefully.

27
flake.lock Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1616847335,
"narHash": "sha256-AQrNtJZRl9P78u+otHNXVxcQzu84vuTJLqynupp335g=",
"owner": "cmacrae",
"repo": "nixpkgs",
"rev": "7745d5338ad3c6cef295f40a732c6a739b1fcc7b",
"type": "github"
},
"original": {
"owner": "cmacrae",
"ref": "fix_spacebar",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

60
flake.nix Normal file
View file

@ -0,0 +1,60 @@
{
description = "A minimal status bar for macOS";
# TODO: Move to official nixpkgs once PR is merged
# https://github.com/NixOS/nixpkgs/pull/117780
inputs.nixpkgs.url = "github:cmacrae/nixpkgs/fix_spacebar";
outputs = { self, nixpkgs }:
let
pkgs = import nixpkgs {
config = {};
system = "x86_64-darwin";
};
buildInputs = with pkgs.darwin.apple_sdk.frameworks; [
Carbon
Cocoa
ScriptingBridge
SkyLight
];
shellInputs = buildInputs ++ [ pkgs.asciidoctor ];
in
{
packages.x86_64-darwin.spacebar =
pkgs.stdenv.mkDerivation rec {
pname = "spacebar";
version = "1.3.0";
src = self;
inherit buildInputs;
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share/man/man1/
cp ./bin/spacebar $out/bin/spacebar
cp ./doc/spacebar.1 $out/share/man/man1/spacebar.1
'';
meta = with pkgs.lib; {
description = "A minimal status bar for macOS";
homepage = "https://github.com/cmacrae/spacebar";
platforms = platforms.darwin;
maintainers = [ maintainers.cmacrae ];
license = licenses.mit;
};
};
overlay = final: prev: {
spacebar = self.packages.x86_64-darwin.spacebar;
};
defaultPackage.x86_64-darwin = self.packages.x86_64-darwin.spacebar;
devShell.x86_64-darwin = pkgs.stdenv.mkDerivation {
name = "spacebar";
buildInputs = shellInputs;
};
};
}