mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-16 00:19:12 +00:00
lib: init XDG-specific subset
This is arguably more suitable for certain environment but Nix ecosystem is already largely Unix-adjacent anyways.
This commit is contained in:
parent
eb4352f925
commit
48949336ff
@ -13,6 +13,7 @@ in pkgs.lib.makeExtensible (self:
|
||||
trivial = callLib ./trivial.nix;
|
||||
data = callLib ./data.nix;
|
||||
math = callLib ./math.nix;
|
||||
xdg = callLib ./xdg.nix;
|
||||
|
||||
# For future references, these are the only attributes that are going to be
|
||||
# exported as part of nixpkgs overlay.
|
||||
@ -43,6 +44,7 @@ in pkgs.lib.makeExtensible (self:
|
||||
inherit (self.trivial) countAttrs filterAttrs';
|
||||
inherit (self.data) importYAML renderTeraTemplate renderMustacheTemplate;
|
||||
inherit (self.fetchers) fetchInternetArchive fetchUgeeDriver;
|
||||
inherit (self.xdg) getXdgDesktop;
|
||||
} // lib.optionalAttrs (builtins ? fetchTree) {
|
||||
flake = callLib ./flake.nix;
|
||||
|
||||
|
31
lib/xdg.nix
Normal file
31
lib/xdg.nix
Normal file
@ -0,0 +1,31 @@
|
||||
{ pkgs, lib, self }:
|
||||
|
||||
rec {
|
||||
/**
|
||||
Naively get the absolute path of a `.desktop` file given a derivation and a
|
||||
name.
|
||||
|
||||
# Arguments
|
||||
|
||||
drv
|
||||
: The derivation.
|
||||
|
||||
name
|
||||
: The name of the `.desktop` file (without the `.desktop` extension).
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
getXdgDesktop :: Derivation -> String -> Path
|
||||
```
|
||||
|
||||
# Example
|
||||
|
||||
```nix
|
||||
getXdgDesktop pkgs.wezterm "org.wezfurlong.wezterm"
|
||||
=> /nix/store/$HASH-wezterm-org.wezterm.wezterm.desktop
|
||||
```
|
||||
*/
|
||||
getXdgDesktop = drv: name:
|
||||
"${drv}/share/applications/${name}.desktop";
|
||||
}
|
@ -27,6 +27,7 @@ in {
|
||||
trivial = callLib ./trivial.nix;
|
||||
data = callLib ./data;
|
||||
math = callLib ./math.nix;
|
||||
xdg = callLib ./xdg.nix;
|
||||
|
||||
# Environment-specific subset.
|
||||
home-manager = callLib ./home-manager.nix;
|
||||
|
14
tests/lib/xdg.nix
Normal file
14
tests/lib/xdg.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ pkgs, lib, self }:
|
||||
|
||||
lib.runTests {
|
||||
testGetXdgDesktop = {
|
||||
expr = self.xdg.getXdgDesktop pkgs.wezterm "org.wezfurlong.wezterm";
|
||||
expected = "${pkgs.wezterm}/share/applications/org.wezfurlong.wezterm.desktop";
|
||||
};
|
||||
|
||||
# This should be a naive function so it should just naively get things.
|
||||
testGetXdgDesktop2 = {
|
||||
expr = self.xdg.getXdgDesktop pkgs.hello "non-existing-desktop";
|
||||
expected = "${pkgs.hello}/share/applications/non-existing-desktop.desktop";
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user