mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
refactor: remove unused library functions, start removing with lib
This commit is contained in:
parent
abbb3f8899
commit
600d890b7f
23 changed files with 91 additions and 248 deletions
10
devShell.nix
10
devShell.nix
|
|
@ -4,6 +4,8 @@ let
|
|||
config = meta;
|
||||
inherit (meta) pkgs;
|
||||
inherit (pkgs) lib;
|
||||
inherit (lib.options) optional;
|
||||
inherit (lib.attrsets) attrValues;
|
||||
nf-actions = pkgs.writeShellScriptBin "nf-actions" ''
|
||||
export START_DIR="$PWD"
|
||||
cd "${toString ./.}"
|
||||
|
|
@ -37,7 +39,7 @@ let
|
|||
darwin-rebuild switch --flake ${toString ./.}#sumireko
|
||||
'';
|
||||
in
|
||||
with lib; pkgs.mkShell {
|
||||
pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
inetutils
|
||||
nf-actions
|
||||
|
|
@ -45,17 +47,17 @@ with lib; pkgs.mkShell {
|
|||
nf-update
|
||||
sumireko-apply
|
||||
] ++ config.runners.lazy.nativeBuildInputs
|
||||
# ++ optional (builtins.getEnv "TRUSTED" != "") (pkgs.writeShellScriptBin "bitw" ''${pkgs.rbw-bitw}/bin/bitw -p gpg://${config.network.nodes.nixos.koishi.kw.secrets.repo.bitw.source} "$@"'')
|
||||
++ lib.optional (builtins.getEnv "TRUSTED" != "") (pkgs.writeShellScriptBin "bitw" ''${pkgs.rbw-bitw}/bin/bitw -p gpg://${config.network.nodes.nixos.koishi.kw.secrets.repo.bitw.source} "$@"'')
|
||||
++ (map
|
||||
(node: writeShellScriptBin "${node.networking.hostName}-sd-img" ''
|
||||
nix build -f . network.nodes.${node.networking.hostName}.system.build.sdImage --show-trace
|
||||
'')
|
||||
(filter (node: node.system.build ? sdImage) (attrValues meta.network.nodes.nixos)))
|
||||
(builtins.filter (node: node.system.build ? sdImage) (attrValues meta.network.nodes.nixos)))
|
||||
++ (map
|
||||
(node: writeShellScriptBin "${node.networking.hostName}-iso-img" ''
|
||||
nix build -f . network.nodes.${node.networking.hostName}.system.build.isoImage --show-trace
|
||||
'')
|
||||
(filter (node: node.system.build ? isoImage) (attrValues meta.network.nodes.nixos)));
|
||||
(builtins.filter (node: node.system.build ? isoImage) (attrValues meta.network.nodes.nixos)));
|
||||
shellHook = ''
|
||||
export HOME_HOSTNAME=$(hostname -s)
|
||||
export NIX_BIN_DIR=${pkgs.nix}/bin
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, tree, ... }: with lib; let
|
||||
{ lib, tree, ... }: let
|
||||
profiles = tree.prev;
|
||||
appendedProfiles = with profiles; {
|
||||
ms-7b86 = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }: with lib; {
|
||||
{ config, lib, pkgs, ... }: {
|
||||
options = {
|
||||
home-manager.users = let
|
||||
applets = { config, nixos, ... }: {
|
||||
|
|
@ -8,9 +8,9 @@
|
|||
blueman-applet.enable = true;
|
||||
};
|
||||
};
|
||||
in mkOption {
|
||||
type = types.attrsOf (types.submoduleWith {
|
||||
modules = singleton applets;
|
||||
in lib.mkOption {
|
||||
type = lib.types.attrsOf (lib.types.submoduleWith {
|
||||
modules = lib.singleton applets;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
networkmanager = {
|
||||
enable = true;
|
||||
connectionConfig = {
|
||||
"ipv6.ip6-privacy" = mkForce 0;
|
||||
"ipv6.ip6-privacy" = lib.mkForce 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,54 +1,54 @@
|
|||
{ config, tf, meta, kw, pkgs, lib, inputs, ... }: with lib; let
|
||||
{ config, tf, meta, kw, pkgs, lib, inputs, ... }: let
|
||||
oci-root = meta.deploy.targets.oci-root.tf;
|
||||
cfg = config.kw.oci;
|
||||
in
|
||||
{
|
||||
options.kw.oci = {
|
||||
base = mkOption {
|
||||
base = lib.mkOption {
|
||||
description = ''
|
||||
Canonical Ubuntu provides an EXT4 root filesystem.
|
||||
Oracle Linux provides an XFS root filesystem.
|
||||
'';
|
||||
type = with types; enum [
|
||||
type = lib.enum [
|
||||
"Canonical Ubuntu"
|
||||
"Oracle Linux"
|
||||
];
|
||||
default = "Canonical Ubuntu";
|
||||
};
|
||||
specs = {
|
||||
shape = mkOption {
|
||||
type = with types; nullOr str;
|
||||
shape = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
};
|
||||
cores = mkOption {
|
||||
type = with types; nullOr int;
|
||||
cores = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
default = null;
|
||||
};
|
||||
ram = mkOption {
|
||||
type = with types; nullOr int;
|
||||
ram = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
default = null;
|
||||
};
|
||||
space = mkOption {
|
||||
type = with types; nullOr int;
|
||||
space = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
network = {
|
||||
privateV4 = mkOption {
|
||||
type = with types; nullOr int;
|
||||
privateV4 = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
default = null;
|
||||
};
|
||||
publicV6 = mkOption {
|
||||
type = with types; nullOr int;
|
||||
publicV6 = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
ad = mkOption {
|
||||
ad = lib.mkOption {
|
||||
description = ''
|
||||
Availability Domain.
|
||||
Important because, for example: EPYC instances can only be provisioned on AD2 in London.
|
||||
'';
|
||||
type = with types; nullOr int;
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
|
@ -57,7 +57,7 @@ in
|
|||
];
|
||||
config =
|
||||
let
|
||||
interface = attrByPath [ cfg.specs.shape ] (throw "Unsupported shape") {
|
||||
interface = lib.attrByPath [ cfg.specs.shape ] (throw "Unsupported shape") {
|
||||
"VM.Standard.A1.Flex" = "enp0s3";
|
||||
"VM.Standard.E2.1.Micro" = "ens3";
|
||||
};
|
||||
|
|
@ -68,7 +68,7 @@ in
|
|||
${interface} = {
|
||||
useDHCP = true;
|
||||
ipv6 = {
|
||||
addresses = mkIf (config.network.addresses.public.nixos.ipv6.enable) [{
|
||||
addresses = lib.mkIf (config.network.addresses.public.nixos.ipv6.enable) [{
|
||||
address = config.network.addresses.public.nixos.ipv6.address;
|
||||
prefixLength = 64;
|
||||
}];
|
||||
|
|
@ -86,18 +86,18 @@ in
|
|||
let
|
||||
addr_ipv6_nix =
|
||||
let
|
||||
prefix = head (splitString "/" (oci-root.resources.oci_kw_subnet.importAttr "ipv6cidr_block"));
|
||||
prefix = lib.head (lib.splitString "/" (oci-root.resources.oci_kw_subnet.importAttr "ipv6cidr_block"));
|
||||
in
|
||||
assert hasSuffix "::" prefix; prefix + toString config.kw.oci.network.publicV6;
|
||||
assert lib.hasSuffix "::" prefix; prefix + toString config.kw.oci.network.publicV6;
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
nixos.ipv6.address = mkIf tf.state.enable addr_ipv6_nix;
|
||||
nixos.ipv6.selfaddress = mkIf tf.state.enable addr_ipv6_nix;
|
||||
nixos.ipv6.address = lib.mkIf tf.state.enable addr_ipv6_nix;
|
||||
nixos.ipv6.selfaddress = lib.mkIf tf.state.enable addr_ipv6_nix;
|
||||
tf.ipv6.address = tf.resources."${config.networking.hostName}_ipv6".refAttr "ip_address";
|
||||
};
|
||||
};
|
||||
firewall.public.interfaces = singleton interface;
|
||||
firewall.public.interfaces = lib.singleton interface;
|
||||
tf = {
|
||||
enable = true;
|
||||
ipv4_attr = "public_ip";
|
||||
|
|
@ -116,7 +116,7 @@ in
|
|||
connection = tf.resources."${config.networking.hostName}".connection.set;
|
||||
};
|
||||
connection = {
|
||||
port = head config.services.openssh.ports;
|
||||
port = lib.head config.services.openssh.ports;
|
||||
};
|
||||
};
|
||||
providers.oci = {
|
||||
|
|
@ -128,13 +128,13 @@ in
|
|||
private_key_path = oci-root.resources.oci_kw_key_file.importAttr "filename";
|
||||
};
|
||||
};
|
||||
resources = mkMerge [{
|
||||
resources = lib.mkMerge [{
|
||||
cloudinit = {
|
||||
provider = "cloudinit";
|
||||
type = "config";
|
||||
dataSource = true;
|
||||
inputs = {
|
||||
part = singleton {
|
||||
part = lib.singleton {
|
||||
content_type = "text/cloud-config";
|
||||
content = "#cloud-config\n" + builtins.toJSON {
|
||||
disable_root = false;
|
||||
|
|
@ -188,7 +188,7 @@ in
|
|||
inherit compartment_id;
|
||||
extended_metadata = { };
|
||||
metadata = {
|
||||
ssh_authorized_keys = concatStringsSep "\n" config.users.users.root.openssh.authorizedKeys.keys;
|
||||
ssh_authorized_keys = lib.concatStringsSep "\n" config.users.users.root.openssh.authorizedKeys.keys;
|
||||
user_data = tf.resources.cloudinit.refAttr "rendered";
|
||||
};
|
||||
shape = cfg.specs.shape;
|
||||
|
|
@ -254,7 +254,7 @@ in
|
|||
direction = "INGRESS";
|
||||
${if protocol == protoValues.TCP then "tcp_options" else "udp_options"} = {
|
||||
destination_port_range =
|
||||
if isAttrs port then {
|
||||
if lib.isAttrs port then {
|
||||
min = port.from;
|
||||
max = port.to;
|
||||
} else {
|
||||
|
|
@ -264,7 +264,7 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
sourceProtos = cartesianProductOfSets {
|
||||
sourceProtos = lib.cartesianProductOfSets {
|
||||
source = [ ipv4 ipv6 ];
|
||||
protocol = [ protoValues.TCP protoValues.UDP ];
|
||||
};
|
||||
|
|
@ -280,7 +280,7 @@ in
|
|||
rules = concatMap mapAllForInterface ([ firewall ] ++ map (interface: firewall.interfaces.${interface}) config.network.firewall.public.interfaces);*/
|
||||
# TODO: use `count` and index into a fancy json or something?
|
||||
in
|
||||
listToAttrs (imap0 (i: rule: nameValuePair "firewall${toString i}" rule) rules)
|
||||
lib.listToAttrs (lib.imap0 (i: rule: lib.nameValuePair "firewall${toString i}" rule) rules)
|
||||
)];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, inputs, tree, ... }: with lib; let
|
||||
{ inputs, tree, ... }: let
|
||||
profiles = tree.prev;
|
||||
appendedProfiles = with profiles; {
|
||||
ubuntu = { config, ... }: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ config, pkgs, lib, ... }: with lib; {
|
||||
{ config, pkgs, lib, ... }: {
|
||||
/*
|
||||
This hardware profile corresponds to any machine which has an AMD Ryzen processor.
|
||||
*/
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
waybarExtend = { config, ... }: {
|
||||
options = {
|
||||
programs.waybar.settings = mkOption {
|
||||
type = with types; listOf (submodule waybarExtend2);
|
||||
type = lib.listOf (lib.submodule waybarExtend2);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
};
|
||||
};*/
|
||||
in mkOption {
|
||||
type = types.attrsOf (types.submoduleWith {
|
||||
type = lib.types.attrsOf (lib.types.submoduleWith {
|
||||
modules = [ waybarExtend polybarExtend ];
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
{ config, tf, lib, ... }: with lib;
|
||||
{ config, tf, lib, ... }:
|
||||
|
||||
{
|
||||
let
|
||||
inherit (lib.attrsets) mapListToAttrs nameValuePair;
|
||||
inherit (lib.modules) mkIf;
|
||||
in {
|
||||
kw.secrets.variables = mapListToAttrs
|
||||
(field:
|
||||
nameValuePair "wireless-${field}" {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
{ config, lib, ... }: with lib;
|
||||
{ config, lib, ... }:
|
||||
|
||||
/*
|
||||
This hardware profile corresponds to the Lenovo Thinkpad x270.
|
||||
*/
|
||||
|
||||
{
|
||||
let
|
||||
inherit (lib.options) mkOption;
|
||||
in {
|
||||
options.home-manager.users = let
|
||||
userTouchpadExtend = { config, nixos, ... }: {
|
||||
wayland.windowManager.sway.config.input."2:7:SynPS/2_Synaptics_TouchPad" = {
|
||||
|
|
@ -18,7 +20,7 @@
|
|||
waybarExtend = { config, ... }: {
|
||||
options = {
|
||||
programs.waybar.settings = mkOption {
|
||||
type = with types; either (listOf (submodule waybarExtend2)) (attrsOf (submodule waybarExtend2));
|
||||
type = lib.types.either (lib.types.listOf (lib.types.submodule waybarExtend2)) (lib.types.attrsOf (lib.types.submodule waybarExtend2));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -28,7 +30,7 @@
|
|||
};
|
||||
};
|
||||
in mkOption {
|
||||
type = types.attrsOf (types.submoduleWith {
|
||||
type = lib.types.attrsOf (lib.types.submoduleWith {
|
||||
modules = [ userTouchpadExtend waybarExtend ];
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, nixos, kw, ... }: with lib;
|
||||
{ config, lib, pkgs, nixos, kw, ... }:
|
||||
|
||||
let
|
||||
commonSettings = {
|
||||
|
|
@ -127,7 +127,7 @@ in
|
|||
};
|
||||
extraNativeMessagingHosts = with pkgs; [
|
||||
tridactyl-native
|
||||
] ++ optional config.programs.buku.enable bukubrow;
|
||||
] ++ lib.optional config.programs.buku.enable bukubrow;
|
||||
};
|
||||
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
|
||||
sponsorblock
|
||||
|
|
|
|||
11
home/mpv.nix
11
home/mpv.nix
|
|
@ -1,6 +1,9 @@
|
|||
{ config, lib, pkgs, ... }: with lib;
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
let
|
||||
inherit (lib.modules) mkMerge mkIf;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
in {
|
||||
programs.mpv = {
|
||||
enable = true;
|
||||
scripts = [ pkgs.mpvScripts.sponsorblock pkgs.mpvScripts.paused ];
|
||||
|
|
@ -98,8 +101,8 @@
|
|||
osd-bar-h = 2.5; # 3.125 default
|
||||
osd-border-size = 2; # font border pixels, default 3
|
||||
term-osd-bar = true;
|
||||
script-opts = lib.concatStringsSep ","
|
||||
(lib.mapAttrsToList (k: v: "${k}=${toString v}") {
|
||||
script-opts = builtins.concatStringsSep ","
|
||||
(mapAttrsToList (k: v: "${k}=${toString v}") {
|
||||
ytdl_hook-ytdl_path = "${pkgs.yt-dlp}/bin/yt-dlp";
|
||||
osc-layout = "slimbox";
|
||||
osc-vidscale = "no";
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
"listrowsfirst"
|
||||
]; in
|
||||
''
|
||||
${if lib.hasSuffix "darwin" pkgs.stdenv.system then ''
|
||||
${if lib.hasSuffix "linux" pkgs.stdenv.system then ''
|
||||
eval $(dircolors)
|
||||
'' else ''
|
||||
''}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{ config, lib, tf, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
let
|
||||
inherit (lib.modules) mkForce;
|
||||
in {
|
||||
kw.secrets.variables = {
|
||||
syncplay-pass = {
|
||||
path = "services/media/syncplay";
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
{ lib }: rec {
|
||||
hexChars =
|
||||
[ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" ];
|
||||
hexCharToInt = char:
|
||||
let
|
||||
pairs = lib.imap0 (lib.flip lib.nameValuePair) hexChars;
|
||||
idx = builtins.listToAttrs pairs;
|
||||
in
|
||||
idx.${lib.toLower char};
|
||||
hexToInt = str:
|
||||
lib.foldl (value: chr: value * 16 + hexCharToInt chr) 0
|
||||
(lib.stringToCharacters str);
|
||||
hextorgba = hex: alpha:
|
||||
(
|
||||
let
|
||||
r_hex = lib.substring 1 2 hex;
|
||||
g_hex = lib.substring 3 2 hex;
|
||||
b_hex = lib.substring 5 2 hex;
|
||||
r_dec = hexToInt r_hex;
|
||||
g_dec = hexToInt g_hex;
|
||||
b_dec = hexToInt b_hex;
|
||||
in
|
||||
"rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, ${toString alpha})"
|
||||
);
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
{ lib }: { folder, defaultFile ? "default.nix", folderPaths ? [ ] }: with lib; let
|
||||
defaultFileFinal =
|
||||
if (defaultFile == "default.nix" && folder == "hosts") then
|
||||
"nixos.nix"
|
||||
else defaultFile;
|
||||
folderModLists = map
|
||||
(folderPath: modList {
|
||||
modulesDir = folderPath;
|
||||
defaultFile = defaultFileFinal;
|
||||
})
|
||||
(filter builtins.pathExists folderPaths);
|
||||
in
|
||||
foldl modListMerge { } folderModLists
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{ lib }: path: excludes:
|
||||
let
|
||||
filterAttrNamesToList = filter: set:
|
||||
lib.foldl' (a: b: a ++ b) [ ]
|
||||
(map (e: if (filter e set.${e}) then [ e ] else [ ]) (lib.attrNames set));
|
||||
in
|
||||
(filterAttrNamesToList (name: type: ! (builtins.elem name excludes) && type == "directory") (builtins.readDir path))
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{ lib }: pathsA: pathsB: with lib; let
|
||||
pathIntersection = intersectLists (attrNames pathsA) (attrNames pathsB);
|
||||
pathMerger = pathA: pathB: { imports = [ pathA pathB ]; };
|
||||
in
|
||||
pathsA // pathsB // genAttrs pathIntersection (key: (pathMerger pathsA.${key} pathsB.${key}))
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
{ lib }: { modulesDir, defaultFile ? "default.nix", importAll ? false }:
|
||||
|
||||
with builtins;
|
||||
|
||||
let
|
||||
isModule = m: lib.isFunction m && (m.isModule or true);
|
||||
filterAttrNamesToList = filter: set:
|
||||
foldl' (a: b: a ++ b) [ ]
|
||||
(map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set));
|
||||
nameValuePair = name: value: { inherit name value; };
|
||||
listToAttrs = foldl' (acc: val: acc // { ${val.name} = val.value; }) { };
|
||||
directories =
|
||||
filterAttrNamesToList (_: type: type == "directory") (readDir modulesDir);
|
||||
files = map (dir: nameValuePair dir (modulesDir + "/${dir}/${defaultFile}"))
|
||||
(filter (f: builtins.pathExists (modulesDir + "/${f}/${defaultFile}")) directories);
|
||||
modules = map
|
||||
({ name, value }:
|
||||
# if the file contains a function, assume it to be a module and pass the path
|
||||
# (for dedup and such). if it contains anything else, pass that.
|
||||
let m = import value;
|
||||
in
|
||||
{
|
||||
inherit name;
|
||||
value = if lib.isFunction m && ! isModule m then m { inherit lib; } else if isModule m && !importAll then value else m;
|
||||
})
|
||||
files;
|
||||
modList = (listToAttrs modules);
|
||||
in
|
||||
modList
|
||||
|
|
@ -7,17 +7,10 @@
|
|||
, isOverlayLib ? false
|
||||
}@args:
|
||||
let
|
||||
colorHelpers = import ./color-helpers.nix { inherit lib; };
|
||||
lib = before // katlib // self;
|
||||
katlib = with before; with katlib; with self;
|
||||
{
|
||||
inherit (colorHelpers) hextorgba;
|
||||
nodeImport = import ./node-import.nix { inherit lib; };
|
||||
virtualHostGen = import ./virtual-host-gen.nix { inherit lib; };
|
||||
domainMerge = import ./domain-merge.nix { inherit lib; };
|
||||
modListMerge = import ./intersect-merge.nix { inherit lib; };
|
||||
modList = import ./module-list.nix { inherit lib; };
|
||||
folderList = import ./folder-list.nix { inherit lib; };
|
||||
};
|
||||
in
|
||||
katlib
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
{ lib }: { config, networkFilter ? [ ], addresses ? [ ], block }: with lib;
|
||||
|
||||
let
|
||||
networks = config.network.addresses;
|
||||
filteredNetworks = filterAttrs (n: v: elem n networkFilter) networks;
|
||||
networkValues = attrValues filteredNetworks;
|
||||
addressList' = concatMap (n: n.out.identifierList) networkValues;
|
||||
addressList = map (n: builtins.unsafeDiscardStringContext n) addressList';
|
||||
hostBlocks = map (host: nameValuePair host block) addressList;
|
||||
in
|
||||
listToAttrs hostBlocks
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, rustPlatform
|
||||
, cmake
|
||||
, pkg-config
|
||||
, zlib
|
||||
, installShellFiles
|
||||
, Security
|
||||
, libiconv
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "exa";
|
||||
version = "0.10.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ogham";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-vChsy/FrJEzTO5O+XFycPMP3jqOeea/hfsC0jJbqUVI=";
|
||||
};
|
||||
|
||||
# Cargo.lock is outdated
|
||||
cargoPatches = [ ./update-cargo-lock.diff ];
|
||||
|
||||
cargoSha256 = "sha256-ah8IjShmivS6IWL3ku/4/j+WNr/LdUnh1YJnPdaFdcM=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
buildInputs = [ zlib ] ++ lib.optionals stdenv.isDarwin [ libiconv Security ];
|
||||
outputs = [ "out" ];
|
||||
|
||||
postInstall = ''
|
||||
installShellCompletion \
|
||||
--name exa completions/completions.bash \
|
||||
--name exa.fish completions/completions.fish \
|
||||
--name _exa completions/completions.zsh
|
||||
'';
|
||||
|
||||
# Some tests fail, but Travis ensures a proper build
|
||||
doCheck = false;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Replacement for 'ls' written in Rust";
|
||||
longDescription = ''
|
||||
exa is a modern replacement for ls. It uses colours for information by
|
||||
default, helping you distinguish between many types of files, such as
|
||||
whether you are the owner, or in the owning group. It also has extra
|
||||
features not present in the original ls, such as viewing the Git status
|
||||
for a directory, or recursing into directories with a tree view. exa is
|
||||
written in Rust, so it’s small, fast, and portable.
|
||||
'';
|
||||
changelog = "https://github.com/ogham/exa/releases/tag/v${version}";
|
||||
homepage = "https://the.exa.website";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ ehegnes lilyball globin fortuneteller2k ];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
diff --git a/Cargo.lock b/Cargo.lock
|
||||
index df94188..ed3a068 100644
|
||||
--- a/Cargo.lock
|
||||
+++ b/Cargo.lock
|
||||
@@ -57,7 +57,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "exa"
|
||||
-version = "0.11.0-pre"
|
||||
+version = "0.10.1"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"datetime",
|
||||
|
|
@ -25,11 +25,11 @@ stdenv.mkDerivation rec {
|
|||
mv * $out
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
meta = {
|
||||
description = "A lightweight file manager with full ShareX, Screencloud support and more";
|
||||
homepage = "https://xbackbone.app/";
|
||||
license = with licenses; agpl3;
|
||||
maintainers = with maintainers; [ kittywitch ];
|
||||
platforms = with platforms; unix;
|
||||
license = lib.licenses.agpl3;
|
||||
maintainers = [ lib.maintainers.kittywitch ];
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
26
tree.nix
26
tree.nix
|
|
@ -1,4 +1,10 @@
|
|||
{ lib }: { config, folder, inputs, ... }@args: with lib; let
|
||||
{ lib }: { config, folder, inputs, ... }@args: let
|
||||
inherit (lib.attrsets) filterAttrs mapAttrs' mapAttrs isAttrs nameValuePair attrValues;
|
||||
inherit (lib.strings) hasPrefix removeSuffix;
|
||||
inherit (lib.lists) imap1 singleton optionals optional sublist;
|
||||
inherit (lib.trivial) pipe;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.modules) evalModules;
|
||||
pureTreeGrab = { base, path }: let
|
||||
realPath = toString path;
|
||||
dirContents = builtins.readDir path;
|
||||
|
|
@ -24,36 +30,36 @@
|
|||
in contents;
|
||||
configTreeStruct = { config, ... }: {
|
||||
options.treeConfig = mkOption {
|
||||
type = with types; attrsOf (submodule ({ name, options, config, ... }: {
|
||||
type = lib.types.attrsOf (lib.types.submodule ({ name, options, config, ... }: {
|
||||
options = {
|
||||
evaluateDefault = mkOption {
|
||||
type = types.bool;
|
||||
type = lib.types.bool;
|
||||
description = "Replace the contents of this branch or leaf with those provided by the evaluation of default.nix.";
|
||||
default = false;
|
||||
};
|
||||
aliasDefault = mkOption {
|
||||
type = types.bool;
|
||||
type = lib.types.bool;
|
||||
description = "Replace the contents of this branch or leaf with the default.nix.";
|
||||
default = false;
|
||||
};
|
||||
excludes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "Exclude files or folders from the recurser.";
|
||||
default = [];
|
||||
};
|
||||
functor = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
type = lib.types.bool;
|
||||
description = "Provide a functor for the path provided";
|
||||
default = false;
|
||||
};
|
||||
external = mkOption {
|
||||
type = types.listOf types.unspecified;
|
||||
type = lib.types.listOf lib.types.unspecified;
|
||||
description = "Add external imports into the functor.";
|
||||
default = [];
|
||||
};
|
||||
excludes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "Exclude files or folders from the functor.";
|
||||
default = [];
|
||||
};
|
||||
|
|
@ -80,9 +86,9 @@
|
|||
else f (path ++ [name]) value;
|
||||
in mapAttrs g set;
|
||||
in f [] (recurse [] set);
|
||||
getPathString = path: concatStringsSep "/" path;
|
||||
getPathString = path: builtins.concatStringsSep "/" path;
|
||||
getConfig = path: default: configTreeModule.${getPathString path} or default;
|
||||
revtail = path: sublist 0 (length path - 1) path;
|
||||
revtail = path: sublist 0 (builtins.length path - 1) path;
|
||||
getConfigRecursive = path: let
|
||||
parentPath = revtail path;
|
||||
in getConfig (path ++ singleton "*") (getConfigRecursive parentPath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue