15 Apr 2025 |
Matt Sturgeon | take a look at the flake's sourceInfo attrset;
The commit hash is available as either rev and shortRev if the repo is clean, or dirtyRev and dirtyShortRev when the repo is dirty. In practice you'll want to access it as sourceInfo.rev or sourceInfo.dirtyRev .
As for the overall hash that should be affected even when dirty: there's sourceInfo.narHash .
You might find it interesting to inspect the available attrs in the repl:
$ nix repl
Nix 2.28.1
Type :? for help.
nix-repl> :lf .
Added 29 variables.
nix-repl> :p sourceInfo
{
lastModified = 1742921445;
lastModifiedDate = "20250325165045";
narHash = "sha256-ACj6k+YN217sS5+UpDeu+pN1HIjDSxASeVgCRcF36ic=";
outPath = "/nix/store/38i7dj4q0hdd2z0byar8vq9is3ifhvdn-source";
rev = "87579c987a86ccd6992e847dd95fb4f0e95809d5";
revCount = 3020;
shortRev = "87579c9";
submodules = false;
}
$ touch test && git add test
$ nix repl
Nix 2.28.1
Type :? for help.
nix-repl> :lf .
warning: Git tree '/home/matt/nixvim/pr' is dirty
Added 28 variables.
nix-repl> :p sourceInfo
{
dirtyRev = "87579c987a86ccd6992e847dd95fb4f0e95809d5-dirty";
dirtyShortRev = "87579c9-dirty";
lastModified = 1742921445;
lastModifiedDate = "20250325165045";
narHash = "sha256-mdW66khbVmSx62kWDW/FwAMEUCQs9sKyS6zAGBXKj0U=";
outPath = "/nix/store/hw7jgd4q25kg83jnnb7c90mw360d38fl-source";
submodules = false;
}
| 21:55:03 |
Matt Sturgeon | * take a look at the flake's sourceInfo attrset;
The commit hash is available as either rev and shortRev if the repo is clean, or dirtyRev and dirtyShortRev when the repo is dirty. In practice you'll want to access it as sourceInfo.rev or sourceInfo.dirtyRev .
As for the overall hash that should be affected even when dirty: there's sourceInfo.narHash .
You might find it interesting to inspect the available attrs in the repl:
$ nix repl
Nix 2.28.1
Type :? for help.
nix-repl> :lf .
Added 29 variables.
nix-repl> :p sourceInfo
{
lastModified = 1742921445;
lastModifiedDate = "20250325165045";
narHash = "sha256-ACj6k+YN217sS5+UpDeu+pN1HIjDSxASeVgCRcF36ic=";
outPath = "/nix/store/38i7dj4q0hdd2z0byar8vq9is3ifhvdn-source";
rev = "87579c987a86ccd6992e847dd95fb4f0e95809d5";
revCount = 3020;
shortRev = "87579c9";
submodules = false;
}
$ touch test && git add test
$ nix repl
Nix 2.28.1
Type :? for help.
nix-repl> :lf .
warning: Git tree '/home/matt/nixvim/pr' is dirty
Added 28 variables.
nix-repl> :p sourceInfo
{
dirtyRev = "87579c987a86ccd6992e847dd95fb4f0e95809d5-dirty";
dirtyShortRev = "87579c9-dirty";
lastModified = 1742921445;
lastModifiedDate = "20250325165045";
narHash = "sha256-mdW66khbVmSx62kWDW/FwAMEUCQs9sKyS6zAGBXKj0U=";
outPath = "/nix/store/hw7jgd4q25kg83jnnb7c90mw360d38fl-source";
submodules = false;
}
Within your flake, these are accessed via the special self input.
outputs =
{self, ...}@inputs:
let
# here you can access most attrs in sourceInfo directly from self
# or alternatively, access self.sourceInfo explicitly
foo = self.narHash;
bar = self.sourceInfo.narHash;
in
builtins.trace self.sourceInfo
{ };
| 21:59:12 |
Matt Sturgeon | * take a look at the flake's sourceInfo attrset;
The commit hash is available as either rev and shortRev if the repo is clean, or dirtyRev and dirtyShortRev when the repo is dirty. In practice you'll want to access it as sourceInfo.rev or sourceInfo.dirtyRev .
As for the overall hash that should be affected even when dirty: there's sourceInfo.narHash .
You might find it interesting to inspect the available attrs in the repl:
$ nix repl
Nix 2.28.1
Type :? for help.
nix-repl> :lf .
Added 29 variables.
nix-repl> :p sourceInfo
{
lastModified = 1742921445;
lastModifiedDate = "20250325165045";
narHash = "sha256-ACj6k+YN217sS5+UpDeu+pN1HIjDSxASeVgCRcF36ic=";
outPath = "/nix/store/38i7dj4q0hdd2z0byar8vq9is3ifhvdn-source";
rev = "87579c987a86ccd6992e847dd95fb4f0e95809d5";
revCount = 3020;
shortRev = "87579c9";
submodules = false;
}
$ touch test && git add test
$ nix repl
Nix 2.28.1
Type :? for help.
nix-repl> :lf .
warning: Git tree '/home/matt/nixvim/pr' is dirty
Added 28 variables.
nix-repl> :p sourceInfo
{
dirtyRev = "87579c987a86ccd6992e847dd95fb4f0e95809d5-dirty";
dirtyShortRev = "87579c9-dirty";
lastModified = 1742921445;
lastModifiedDate = "20250325165045";
narHash = "sha256-mdW66khbVmSx62kWDW/FwAMEUCQs9sKyS6zAGBXKj0U=";
outPath = "/nix/store/hw7jgd4q25kg83jnnb7c90mw360d38fl-source";
submodules = false;
}
Within your flake, these are accessed via the special self input, which represents the fully evaluated flake.
outputs =
{self, ...}@inputs:
let
# here you can access most attrs in sourceInfo directly from self
# or alternatively, access self.sourceInfo explicitly
foo = self.narHash;
bar = self.sourceInfo.narHash;
in
builtins.trace self.sourceInfo
{ };
| 21:59:48 |
pcarrier | thanks, brilliant | 22:45:36 |
16 Apr 2025 |
| wesleyjrz joined the room. | 00:19:48 |
| softwing 🩷💛🤍💜💙 (he/they/it) joined the room. | 01:04:55 |
| softwing 🩷💛🤍💜💙 (he/they/it) changed their display name from softwing 🩷💛🤍💜💙 (they/it) to softwing 🩷💛🤍💜💙 (he/they/it/she). | 02:42:25 |
| Lukas joined the room. | 10:57:51 |
| @philospher:tarnkappe.info joined the room. | 22:19:49 |
| Deus_YI_∞ changed their display name from dev_el_∞ to deus_el_∞. | 22:49:59 |
| Deus_YI_∞ changed their display name from deus_el_∞ to Deus_YI_∞. | 22:52:32 |
17 Apr 2025 |
| skynet joined the room. | 00:15:37 |
| NixOS Moderation Bot banned @philospher:tarnkappe.info (spam). | 00:57:20 |
| @mmkaram:matrix.org left the room. | 04:34:51 |
| @gabyx:matrix.org joined the room. | 09:21:30 |
| @gabyx:matrix.org left the room. | 09:22:29 |
| @praneethsarode:matrix.org left the room. | 15:17:53 |
| Zowie 🏳️⚧️ joined the room. | 16:01:38 |
| Emre Ongun joined the room. | 20:05:24 |
| Emre Ongun changed their display name from Emre NGN to Emre Ongun. | 20:11:59 |
| Emre Ongun set a profile picture. | 20:16:11 |
18 Apr 2025 |
| amadALTuzia joined the room. | 02:58:51 |
| amadALTuzia changed their display name from Artur Manuel to amadALTuzia. | 03:24:29 |
19 Apr 2025 |
| cardinalityofm joined the room. | 04:12:22 |
| vewil joined the room. | 08:53:32 |
| jopejoe1 (4094@eh22) changed their display name from jopejoe1 to jopejoe1 (4094@eh22). | 13:00:14 |
| @ochoa:matrix.org left the room. | 21:30:17 |
20 Apr 2025 |
| cardinalityofm set a profile picture. | 01:16:07 |
| cardinalityofm changed their profile picture. | 01:16:10 |
| orhosko joined the room. | 08:12:05 |