!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1629 Members
Nix programming language291 Servers

Load older messages


SenderMessageTime
15 Apr 2025
@mattsturg:matrix.orgMatt 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
@mattsturg:matrix.orgMatt 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
@mattsturg:matrix.orgMatt 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
@pc:rrier.frpcarrierthanks, brilliant22:45:36
16 Apr 2025
@wesleyjrz:matrix.orgwesleyjrz joined the room.00:19:48
@het_dinhe-galju:tchncs.desoftwing 🩷💛🤍💜💙 (he/they/it) joined the room.01:04:55
@het_dinhe-galju:tchncs.desoftwing 🩷💛🤍💜💙 (he/they/it) changed their display name from softwing 🩷💛🤍💜💙 (they/it) to softwing 🩷💛🤍💜💙 (he/they/it/she).02:42:25
@vimmotion:matrix.orgLukas joined the room.10:57:51
@philospher:tarnkappe.info@philospher:tarnkappe.info joined the room.22:19:49
@ivan_ermakov:matrix.orgDeus_YI_∞ changed their display name from dev_el_∞ to deus_el_∞.22:49:59
@ivan_ermakov:matrix.orgDeus_YI_∞ changed their display name from deus_el_∞ to Deus_YI_∞.22:52:32
17 Apr 2025
@skynet1197900:matrix.orgskynet joined the room.00:15:37
@mjolnir:nixos.orgNixOS Moderation Bot banned @philospher:tarnkappe.info@philospher:tarnkappe.info (spam).00:57:20
@mmkaram:matrix.org@mmkaram:matrix.org left the room.04:34:51
@gabyx:matrix.org@gabyx:matrix.org joined the room.09:21:30
@gabyx:matrix.org@gabyx:matrix.org left the room.09:22:29
@praneethsarode:matrix.org@praneethsarode:matrix.org left the room.15:17:53
@zowie:zowi.eeZowie 🏳️‍⚧️ joined the room.16:01:38
@emregnu:matrix.orgEmre Ongun joined the room.20:05:24
@emregnu:matrix.orgEmre Ongun changed their display name from Emre NGN to Emre Ongun.20:11:59
@emregnu:matrix.orgEmre Ongun set a profile picture.20:16:11
18 Apr 2025
@amadaluzia:pub.solaramadALTuzia joined the room.02:58:51
@amadaluzia:pub.solaramadALTuzia changed their display name from Artur Manuel to amadALTuzia.03:24:29
19 Apr 2025
@cardinalityofm:matrix.orgcardinalityofm joined the room.04:12:22
@vewil56528:matrix.orgvewil joined the room.08:53:32
@jopejoe1:matrix.orgjopejoe1 (4094@eh22) changed their display name from jopejoe1 to jopejoe1 (4094@eh22).13:00:14
@ochoa:matrix.org@ochoa:matrix.org left the room.21:30:17
20 Apr 2025
@cardinalityofm:matrix.orgcardinalityofm set a profile picture.01:16:07
@cardinalityofm:matrix.orgcardinalityofm changed their profile picture.01:16:10
@cikokaro:matrix.orgorhosko joined the room.08:12:05

Show newer messages


Back to Room ListRoom Version: 6