Skip to content

Commit b393d4d

Browse files
committed
add nix install option
1 parent c0290f6 commit b393d4d

File tree

4 files changed

+165
-14
lines changed

4 files changed

+165
-14
lines changed

README.md

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
It's a cli tool to manage work times.
44

55
<!-- TOC -->
6-
* [worktimers](#worktimers)
7-
* [Usage](#usage)
8-
* [start working](#start-working)
9-
* [stop working](#stop-working)
10-
* [list worked intervals](#list-worked-intervals)
11-
* [Installation](#installation)
12-
* [install release](#install-release)
13-
* [install from source](#install-from-source)
14-
* [add config](#add-config)
15-
* [Development](#development)
16-
* [create a release](#create-a-release)
6+
- [worktimers](#worktimers)
7+
- [Usage](#usage)
8+
- [start working](#start-working)
9+
- [stop working](#stop-working)
10+
- [list worked intervals](#list-worked-intervals)
11+
- [Installation](#installation)
12+
- [install release](#install-release)
13+
- [install from source](#install-from-source)
14+
- [install local with nix](#install-local-with-nix)
15+
- [install via nix home-manager](#install-via-nix-home-manager)
16+
- [add config](#add-config)
17+
- [Development](#development)
18+
- [create a release](#create-a-release)
1719
<!-- TOC -->
1820

1921
## Usage
@@ -68,6 +70,34 @@ brew install rustup-init
6870
make install
6971
```
7072

73+
## install local with nix
74+
```shell
75+
nix build
76+
```
77+
78+
## install via nix home-manager
79+
```bash
80+
# move to home-manager config. e.g.:
81+
cd ~/.config/home-manager
82+
83+
# add this as input;
84+
actpkg = {
85+
url = "github:sejoharp/act";
86+
};
87+
88+
# optional: update index
89+
nix flake lock --update-input actpkg
90+
91+
# add this to packages:
92+
inputs.reposyncpkg.packages.${pkgs.stdenv.system}.default
93+
94+
# build generation
95+
nh home build .
96+
97+
# switch generation
98+
nh home switch .
99+
```
100+
71101
### add config
72102

73103
add `.worktimers.json` to your home directory and adjust the following content:
@@ -81,8 +111,19 @@ add `.worktimers.json` to your home directory and adjust the following content:
81111

82112
## Development
83113

114+
84115
### create a release
85-
1. make a commit
86-
2. push it
87-
3. github actions will create a release
116+
```bash
117+
# bump version (patch by default)
118+
make version-update
119+
120+
# create a git commit
121+
git add ...
122+
git commit ...
123+
124+
# tag the commit
125+
make tag-release
88126

127+
# push commit and tag
128+
make push-release
129+
```

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
description = "Rust example flake for Zero to Nix";
3+
4+
inputs = {
5+
# Latest stable Nixpkgs
6+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
7+
};
8+
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
}:
14+
let
15+
pkgs = import <nixpkgs> { };
16+
manifest = (nixpkgs.lib.importTOML ./Cargo.toml).package;
17+
18+
# Systems supported
19+
allSystems = [
20+
"x86_64-linux" # 64-bit Intel/AMD Linux
21+
"aarch64-linux" # 64-bit ARM Linux
22+
"x86_64-darwin" # 64-bit Intel macOS
23+
"aarch64-darwin" # 64-bit ARM macOS
24+
];
25+
26+
# Helper to provide system-specific attributes
27+
forAllSystems =
28+
f:
29+
nixpkgs.lib.genAttrs allSystems (
30+
system:
31+
f {
32+
pkgs = import nixpkgs { inherit system; };
33+
}
34+
);
35+
in
36+
{
37+
packages = forAllSystems (
38+
{ pkgs }:
39+
{
40+
default = pkgs.rustPlatform.buildRustPackage {
41+
name = manifest.name;
42+
version = manifest.version;
43+
src = pkgs.lib.cleanSource ./.;
44+
cargoLock = {
45+
lockFile = ./Cargo.lock;
46+
};
47+
};
48+
}
49+
);
50+
};
51+
}

scripts/bump-version.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
CURRENT_VERSION=$(grep '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
5+
echo "Current version: $CURRENT_VERSION"
6+
7+
case "${1:-patch}" in
8+
"patch")
9+
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
10+
;;
11+
"minor")
12+
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$(NF-1) = $(NF-1) + 1; $NF = 0} 1' | sed 's/ /./g')
13+
;;
14+
"major")
15+
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$1 = $1 + 1; $2 = 0; $3 = 0} 1' | sed 's/ /./g')
16+
;;
17+
*)
18+
NEW_VERSION="$1"
19+
;;
20+
esac
21+
22+
echo "New version: $NEW_VERSION"
23+
24+
# Fix for macOS: Use sed -i '' (empty string for no backup)
25+
if [[ "$OSTYPE" == "darwin"* ]]; then
26+
sed -i '' "s/^version = \".*\"/version = \"$NEW_VERSION\"/" Cargo.toml
27+
else
28+
sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" Cargo.toml
29+
fi
30+
cargo check --quiet
31+
32+
echo "Updated Cargo.toml: $(grep '^version = ' Cargo.toml)"

0 commit comments

Comments
 (0)