diff --git a/docs/default.nix b/docs/default.nix index c85b2f7..b6a8dbb 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -30,9 +30,8 @@ let class = "wrapperManager"; }).options; - # Based from nixpkgs' and home-manager's code. - gitHubDeclaration = user: repo: subpath: - { + # Based from nixpkgs' and home-manager's code. + gitHubDeclaration = user: repo: subpath: { url = "https://github.com/${user}/${repo}/blob/master/${subpath}"; name = "<${repo}/${subpath}>"; }; @@ -42,16 +41,21 @@ let { options = if includeModuleSystemOptions then options else builtins.removeAttrs options [ "_module" ]; - transformOptions = opt: - opt // { - declarations = map (decl: + transformOptions = + opt: + opt + // { + declarations = map ( + decl: if lib.hasPrefix src (toString decl) then - gitHubDeclaration "foo-dogsquared" "nix-module-wrapper-manager-fds" - (lib.removePrefix "/" (lib.removePrefix src (toString decl))) + gitHubDeclaration "foo-dogsquared" "nix-module-wrapper-manager-fds" ( + lib.removePrefix "/" (lib.removePrefix src (toString decl)) + ) else if decl == "lib/modules.nix" then gitHubDeclaration "NixOS" "nixpkgs" decl else - decl) opt.declarations; + decl + ) opt.declarations; }; } // builtins.removeAttrs args [ @@ -106,7 +110,9 @@ in ]; }; in - { baseUrl ? "https://foo-dogsquared.github.io/nix-module-wrapper-manager-fds" }: + { + baseUrl ? "https://foo-dogsquared.github.io/nix-module-wrapper-manager-fds", + }: buildHugoSite { pname = "wrapper-manager-docs"; @@ -126,7 +132,10 @@ in vendorHash = "sha256-UDDCYQB/kdYT63vRlRzL6lOePl9F7j3eUIHX/m6rwEs="; - buildFlags = [ "--baseURL" baseUrl ]; + buildFlags = [ + "--baseURL" + baseUrl + ]; nativeBuildInputs = [ asciidoctorWrapped diff --git a/docs/gemset.nix b/docs/gemset.nix index 1b5f391..11fe6e8 100644 --- a/docs/gemset.nix +++ b/docs/gemset.nix @@ -1,339 +1,421 @@ { asciidoctor = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1wyxgwmnz9bw377r3lba26b090hbsq9qnbw8575a1prpy83qh82j"; type = "gem"; }; version = "2.0.23"; }; asciidoctor-diagram = { - dependencies = ["asciidoctor" "asciidoctor-diagram-ditaamini" "asciidoctor-diagram-plantuml" "rexml"]; - groups = ["default"]; - platforms = []; + dependencies = [ + "asciidoctor" + "asciidoctor-diagram-ditaamini" + "asciidoctor-diagram-plantuml" + "rexml" + ]; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1214scxm36k409gfy3wilfqx3akrm52r530zmra6cmmf6d22c5q4"; type = "gem"; }; version = "2.3.1"; }; asciidoctor-diagram-batik = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0220xqxmkmimxmhsqhlbr0hslijvnhzdds3s6h6fxbxqrrmm0jrl"; type = "gem"; }; version = "1.17"; }; asciidoctor-diagram-ditaamini = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "13h65bfbq7hc7z3kqn0m28w9c6ap7fikpjcvsdga6jg01slb4c56"; type = "gem"; }; version = "1.0.3"; }; asciidoctor-diagram-plantuml = { - dependencies = ["asciidoctor-diagram-batik"]; - groups = ["default"]; - platforms = []; + dependencies = [ "asciidoctor-diagram-batik" ]; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1ppl5nsq40x11731ciahi89k5yvszlm12pml1pqaj0lwbi7ww6x0"; type = "gem"; }; version = "1.2024.5"; }; asciidoctor-foodogsquared-extensions = { - dependencies = ["asciidoctor" "rugged"]; - groups = ["default"]; - platforms = []; + dependencies = [ + "asciidoctor" + "rugged" + ]; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0fm6shyysj51wi4s7nnb643j2mphp68fh44gmr83x8n613hg9a4l"; type = "gem"; }; version = "1.2.1"; }; ast = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "04nc8x27hlzlrr5c2gn7mar4vdr0apw5xg22wp6m8dx3wqr04a0y"; type = "gem"; }; version = "2.4.2"; }; concurrent-ruby = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0skwdasxq7mnlcccn6aqabl7n9r3jd7k19ryzlzzip64cn4x572g"; type = "gem"; }; version = "1.3.3"; }; json = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0b4qsi8gay7ncmigr0pnbxyb17y3h8kavdyhsh7nrlqwr35vb60q"; type = "gem"; }; version = "2.7.2"; }; language_server-protocol = { - groups = ["default" "development" "lint"]; - platforms = []; + groups = [ + "default" + "development" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0gvb1j8xsqxms9mww01rmdl78zkd72zgxaap56bhv8j45z05hp1x"; type = "gem"; }; version = "3.17.0.3"; }; logger = { - groups = ["default" "development"]; - platforms = []; + groups = [ + "default" + "development" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0gpg8gzi0xwymw4aaq2iafcbx31i3xzkg3fb30mdxn1d4qhc3dqa"; type = "gem"; }; version = "1.6.0"; }; open-uri-cached = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "03v0if3jlvbclnd6jgjk94fbhf0h2fq1wxr0mbx7018sxzm0biwr"; type = "gem"; }; version = "1.0.0"; }; parallel = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "145bn5q7ysnjj02jdf1x4nc1f0xxrv7ihgz9yr1j7sinmawqkq0j"; type = "gem"; }; version = "1.25.1"; }; parser = { - dependencies = ["ast" "racc"]; - groups = ["default" "lint"]; - platforms = []; + dependencies = [ + "ast" + "racc" + ]; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "10ly2wind06nylyqa5724ld2l0l46d3ag4fm04ifjgw7qdlpf94d"; type = "gem"; }; version = "3.3.4.0"; }; prism = { - groups = ["default" "development"]; - platforms = []; + groups = [ + "default" + "development" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "05j9bcxdz6wfnrjn32zvdwj1qsbp88mwx3rv7g256gziya6avc2r"; type = "gem"; }; version = "0.30.0"; }; racc = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "021s7maw0c4d9a6s07vbmllrzqsj2sgmrwimlh8ffkvwqdjrld09"; type = "gem"; }; version = "1.8.0"; }; rainbow = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0smwg4mii0fm38pyb5fddbmrdpifwv22zv3d3px2xx497am93503"; type = "gem"; }; version = "3.1.1"; }; rake = { - groups = ["development"]; - platforms = []; + groups = [ "development" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "17850wcwkgi30p7yqh60960ypn7yibacjjha0av78zaxwvd3ijs6"; type = "gem"; }; version = "13.2.1"; }; rbs = { - dependencies = ["logger"]; - groups = ["default" "development"]; - platforms = []; + dependencies = [ "logger" ]; + groups = [ + "default" + "development" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1fzk0a3d68fglnkwpaz07npi929y1kh2hh1j63y04943vvshyjmc"; type = "gem"; }; version = "3.5.2"; }; regexp_parser = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0ik40vcv7mqigsfpqpca36hpmnx0536xa825ai5qlkv3mmkyf9ss"; type = "gem"; }; version = "2.9.2"; }; rexml = { - dependencies = ["strscan"]; - groups = ["default" "lint"]; - platforms = []; + dependencies = [ "strscan" ]; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "09f3sw7f846fpcpwdm362ylqldwqxpym6z0qpld4av7zisrrzbrl"; type = "gem"; }; version = "3.3.1"; }; rouge = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "072qvvrcqj0yfr3b0j932mlhvn41i38bq37z7z07i3ikagndkqwy"; type = "gem"; }; version = "4.3.0"; }; rubocop = { - dependencies = ["json" "language_server-protocol" "parallel" "parser" "rainbow" "regexp_parser" "rexml" "rubocop-ast" "ruby-progressbar" "unicode-display_width"]; - groups = ["lint"]; - platforms = []; + dependencies = [ + "json" + "language_server-protocol" + "parallel" + "parser" + "rainbow" + "regexp_parser" + "rexml" + "rubocop-ast" + "ruby-progressbar" + "unicode-display_width" + ]; + groups = [ "lint" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "18g462bccr0rvszc7kirr89laggdf6254p7pqsckk3izg901chv2"; type = "gem"; }; version = "1.65.0"; }; rubocop-ast = { - dependencies = ["parser"]; - groups = ["default" "lint"]; - platforms = []; + dependencies = [ "parser" ]; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "063qgvqbyv354icl2sgx758z22wzq38hd9skc3n96sbpv0cdc1qv"; type = "gem"; }; version = "1.31.3"; }; ruby-lsp = { - dependencies = ["language_server-protocol" "prism" "rbs" "sorbet-runtime"]; - groups = ["development"]; - platforms = []; + dependencies = [ + "language_server-protocol" + "prism" + "rbs" + "sorbet-runtime" + ]; + groups = [ "development" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1kvyk0cald1cw6fqxy5w68la1gnc1nv2mqx8myijjsbcf9npjbp8"; type = "gem"; }; version = "0.17.7"; }; ruby-progressbar = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0cwvyb7j47m7wihpfaq7rc47zwwx9k4v7iqd9s1xch5nm53rrz40"; type = "gem"; }; version = "1.13.0"; }; rugged = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1sccng15h8h3mcjxfgvxy85lfpswbj0nhmzwwsqdffbzqgsb2jch"; type = "gem"; }; version = "1.7.2"; }; slim = { - dependencies = ["temple" "tilt"]; - groups = ["default"]; - platforms = []; + dependencies = [ + "temple" + "tilt" + ]; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1rqk7jn66wgx50b18ndhbppjq55rbcwgqg1rbhnhxwiggvzisdbj"; type = "gem"; }; version = "5.2.1"; }; sorbet-runtime = { - groups = ["default" "development"]; - platforms = []; + groups = [ + "default" + "development" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "122702d5cmrbaydcqfjksh1d78g0mq69h77zd4yljwjrc50jz70b"; type = "gem"; }; version = "0.5.11481"; }; strscan = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0mamrl7pxacbc79ny5hzmakc9grbjysm3yy6119ppgsg44fsif01"; type = "gem"; }; version = "3.1.0"; }; temple = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0fwia5hvc1xz9w7vprzjnsym3v9j5l9ggdvy70jixbvpcpz4acfz"; type = "gem"; }; version = "0.10.3"; }; tilt = { - groups = ["default"]; - platforms = []; + groups = [ "default" ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "0kds7wkxmb038cwp6ravnwn8k65ixc68wpm8j5jx5bhx8ndg4x6z"; type = "gem"; }; version = "2.4.0"; }; unicode-display_width = { - groups = ["default" "lint"]; - platforms = []; + groups = [ + "default" + "lint" + ]; + platforms = [ ]; source = { - remotes = ["https://rubygems.org"]; + remotes = [ "https://rubygems.org" ]; sha256 = "1d0azx233nags5jx3fqyr23qa2rhgzbhv8pxp46dgbg1mpf82xky"; type = "gem"; }; diff --git a/flake.nix b/flake.nix index b7a0568..840e9a7 100644 --- a/flake.nix +++ b/flake.nix @@ -61,9 +61,9 @@ website = docs.website { }; }; - checks = - { inherit (tests) lib; } - // lib.mapAttrs' (n: v: lib.nameValuePair "config-test-${n}" v) tests.configs; + checks = { + inherit (tests) lib; + } // lib.mapAttrs' (n: v: lib.nameValuePair "config-test-${n}" v) tests.configs; } )); } diff --git a/lib/default.nix b/lib/default.nix index 6638733..c32739a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -25,7 +25,12 @@ pkgs.lib.makeExtensible ( modules = callLibs ./modules.nix; inherit (self.env) build eval; - inherit (self.utils) getBin getLibexec getXdgDataDirs getXdgConfigDirs; + inherit (self.utils) + getBin + getLibexec + getXdgDataDirs + getXdgConfigDirs + ; inherit (self.modules) makeWraparound; } ) diff --git a/lib/modules.nix b/lib/modules.nix index a890582..ba8c2b3 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -16,37 +16,36 @@ rec { another program. Several examples of this includes sudo, Bubblewrap, and Gamescope. */ - makeWraparound = { - arg0, - under, - underFlags ? [ ], - underSeparator ? "", - ... - }@module: + makeWraparound = + { + arg0, + under, + underFlags ? [ ], + underSeparator ? "", + ... + }@module: let # These are the attrnames that would be overtaken with the function and # will be merged anyways so... functionArgs = builtins.functionArgs makeWraparound; module' = lib.removeAttrs module (lib.attrNames functionArgs); in - lib.mkMerge [ - { - arg0 = under; + lib.mkMerge [ + { + arg0 = under; - # This should be the very first things to be in the arguments so - # we're just making sure that it is the case. The priority is chosen - # arbitrarily just in case the user already has `prependArgs` values - # with `lib.mkBefore` for the original arg0. - prependArgs = lib.mkOrder 250 ( - underFlags - ++ lib.optionals (underSeparator != "") [ underSeparator ] - ++ [ arg0 ] - ); - } + # This should be the very first things to be in the arguments so + # we're just making sure that it is the case. The priority is chosen + # arbitrarily just in case the user already has `prependArgs` values + # with `lib.mkBefore` for the original arg0. + prependArgs = lib.mkOrder 250 ( + underFlags ++ lib.optionals (underSeparator != "") [ underSeparator ] ++ [ arg0 ] + ); + } - # It's constructed like this to make it ergonomic to use. The user can - # simply delete the makeWraparound exclusive arguments and still work - # normally. - module' - ]; + # It's constructed like this to make it ergonomic to use. The user can + # simply delete the makeWraparound exclusive arguments and still work + # normally. + module' + ]; } diff --git a/modules/env/common.nix b/modules/env/common.nix index 04b4d72..6efa46a 100644 --- a/modules/env/common.nix +++ b/modules/env/common.nix @@ -23,7 +23,8 @@ let ) ( - { lib, ... }: { + { lib, ... }: + { options.enableInstall = lib.mkOption { type = lib.types.bool; default = cfg.enableInstall; diff --git a/modules/env/home-manager/default.nix b/modules/env/home-manager/default.nix index e7cab63..3de71b0 100644 --- a/modules/env/home-manager/default.nix +++ b/modules/env/home-manager/default.nix @@ -7,7 +7,10 @@ let cfg = config.wrapper-manager; - wmDocs = import ../../../docs { inherit pkgs; inherit (cfg.documentation) extraModules; }; + wmDocs = import ../../../docs { + inherit pkgs; + inherit (cfg.documentation) extraModules; + }; in { imports = [ ../common.nix ]; @@ -39,7 +42,7 @@ in let validPackages = lib.filterAttrs (_: wrapper: wrapper.enableInstall) cfg.packages; in - lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages; + lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages; }) ]; } diff --git a/modules/env/nixos/default.nix b/modules/env/nixos/default.nix index 8d8572c..9a74e1c 100644 --- a/modules/env/nixos/default.nix +++ b/modules/env/nixos/default.nix @@ -7,7 +7,10 @@ let cfg = config.wrapper-manager; - wmDocs = import ../../../docs { inherit pkgs; inherit (cfg.documentation) extraModules; }; + wmDocs = import ../../../docs { + inherit pkgs; + inherit (cfg.documentation) extraModules; + }; in { imports = [ ../common.nix ]; @@ -37,7 +40,7 @@ in let validPackages = lib.filterAttrs (_: wrapper: wrapper.enableInstall) cfg.packages; in - lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages; + lib.mapAttrsToList (_: wrapper: wrapper.build.toplevel) validPackages; }) ]; } diff --git a/modules/wrapper-manager/base.nix b/modules/wrapper-manager/base.nix index 55c8ea3..12d0faa 100644 --- a/modules/wrapper-manager/base.nix +++ b/modules/wrapper-manager/base.nix @@ -8,9 +8,20 @@ let envConfig = config; - toStringType = (with lib.types; coercedTo (oneOf [str path int float bool]) (x: "${x}") str) // { - description = "string and select types (numbers, boolean, and path) convertible to it"; - }; + toStringType = + ( + with lib.types; + coercedTo (oneOf [ + str + path + int + float + bool + ]) (x: "${x}") str + ) + // { + description = "string and select types (numbers, boolean, and path) convertible to it"; + }; envSubmodule = { config, @@ -174,7 +185,12 @@ let n: v: if v.action == "unset" then "--${v.action} ${lib.escapeShellArg n}" - else if lib.elem v.action [ "prefix" "suffix" ] then + else if + lib.elem v.action [ + "prefix" + "suffix" + ] + then "--${v.action} ${lib.escapeShellArg n} ${lib.escapeShellArg v.separator} ${lib.escapeShellArg (lib.concatStringsSep v.separator v.value)}" else "--${v.action} ${lib.escapeShellArg n} ${lib.escapeShellArg v.value}" diff --git a/modules/wrapper-manager/build.nix b/modules/wrapper-manager/build.nix index 84d0a9e..47a146f 100644 --- a/modules/wrapper-manager/build.nix +++ b/modules/wrapper-manager/build.nix @@ -8,7 +8,10 @@ { options.build = { variant = lib.mkOption { - type = lib.types.enum [ "binary" "shell" ]; + type = lib.types.enum [ + "binary" + "shell" + ]; description = '' Indicates the type of wrapper to be made. By default, wrapper-manager sets this to `binary`. @@ -48,9 +51,12 @@ let inherit (config.build) variant; makeWrapperArg0 = - if variant == "binary" then "makeBinaryWrapper" - else if variant == "shell" then "makeShellWrapper" - else "makeWrapper"; + if variant == "binary" then + "makeBinaryWrapper" + else if variant == "shell" then + "makeShellWrapper" + else + "makeWrapper"; mkWrapBuild = wrappers: @@ -62,28 +68,35 @@ desktopEntries = mkDesktopEntries (lib.attrValues config.xdg.desktopEntries); in - if lib.isList config.basePackages then - pkgs.symlinkJoin { - passthru = config.build.extraPassthru; - name = "wrapper-manager-fds-wrapped-package"; - paths = desktopEntries ++ config.basePackages; - nativeBuildInputs = - if variant == "binary" then [ pkgs.makeBinaryWrapper ] - else if variant == "shell" then [ pkgs.makeShellWrapper ] - else [ ]; - postBuild = '' - ${config.build.extraSetup} - ${mkWrapBuild (lib.attrValues config.wrappers)} - ''; - } - else - config.basePackages.overrideAttrs (final: prev: { + if lib.isList config.basePackages then + pkgs.symlinkJoin { + passthru = config.build.extraPassthru; + name = "wrapper-manager-fds-wrapped-package"; + paths = desktopEntries ++ config.basePackages; + nativeBuildInputs = + if variant == "binary" then + [ pkgs.makeBinaryWrapper ] + else if variant == "shell" then + [ pkgs.makeShellWrapper ] + else + [ ]; + postBuild = '' + ${config.build.extraSetup} + ${mkWrapBuild (lib.attrValues config.wrappers)} + ''; + } + else + config.basePackages.overrideAttrs ( + final: prev: { nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ ( - if variant == "binary" then [ pkgs.makeBinaryWrapper ] - else if variant == "shell" then [ pkgs.makeShellWrapper ] - else [ ] + if variant == "binary" then + [ pkgs.makeBinaryWrapper ] + else if variant == "shell" then + [ pkgs.makeShellWrapper ] + else + [ ] ) ++ lib.optionals (config.xdg.desktopEntries != { }) [ pkgs.copyDesktopItems ]; desktopItems = (prev.desktopItems or [ ]) ++ desktopEntries; @@ -91,10 +104,14 @@ ${prev.postFixup or ""} ${mkWrapBuild (lib.attrValues config.wrappers)} ''; - passthru = lib.recursiveUpdate (prev.passthru or { }) (config.build.extraPassthru // { - unwrapped = config.basePackages; - }); - }); + passthru = lib.recursiveUpdate (prev.passthru or { }) ( + config.build.extraPassthru + // { + unwrapped = config.basePackages; + } + ); + } + ); }; }; } diff --git a/modules/wrapper-manager/files.nix b/modules/wrapper-manager/files.nix index 9da118d..69c7b67 100644 --- a/modules/wrapper-manager/files.nix +++ b/modules/wrapper-manager/files.nix @@ -1,55 +1,69 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.files; - filesModule = { name, lib, config, options, ... }: { - options = { - target = lib.mkOption { - type = lib.types.nonEmptyStr; - description = '' - Path of the file relative to the derivation output path. - ''; - default = name; - example = "share/applications/org.example.App1.desktop"; + filesModule = + { + name, + lib, + config, + options, + ... + }: + { + options = { + target = lib.mkOption { + type = lib.types.nonEmptyStr; + description = '' + Path of the file relative to the derivation output path. + ''; + default = name; + example = "share/applications/org.example.App1.desktop"; + }; + + source = lib.mkOption { + type = lib.types.path; + description = "Path of the file to be linked."; + }; + + text = lib.mkOption { + type = with lib.types; nullOr lines; + description = '' + Text content of the given filesystem path. + ''; + default = null; + example = '' + key=value + hello=world + ''; + }; + + mode = lib.mkOption { + type = lib.types.strMatching "[0-7]{0,4}"; + default = "0644"; + example = "0600"; + description = '' + Permissions to be given to the file. By default, it is given with a + symlink. + ''; + }; }; - source = lib.mkOption { - type = lib.types.path; - description = "Path of the file to be linked."; - }; - - text = lib.mkOption { - type = with lib.types; nullOr lines; - description = '' - Text content of the given filesystem path. - ''; - default = null; - example = '' - key=value - hello=world - ''; - }; - - mode = lib.mkOption { - type = lib.types.strMatching "[0-7]{0,4}"; - default = "0644"; - example = "0600"; - description = '' - Permissions to be given to the file. By default, it is given with a - symlink. - ''; + config = { + source = lib.mkIf (config.text != null) ( + let + name' = "wrapper-manager-filesystem-${lib.replaceStrings [ "/" ] [ "-" ] name}"; + in + lib.modules.mkDerivedConfig options.text (pkgs.writeText name') + ); }; }; - - config = { - source = lib.mkIf (config.text != null) ( - let - name' = "wrapper-manager-filesystem-${lib.replaceStrings ["/"] ["-"] name}"; - in lib.modules.mkDerivedConfig options.text (pkgs.writeText name') - ); - }; - }; in { options.files = lib.mkOption { @@ -79,27 +93,38 @@ in }; config = lib.mkIf (cfg != { }) { - build.extraSetup = let - installFiles = acc: n: v: let - source = lib.escapeShellArg v.source; - target = lib.escapeShellArg v.target; - target' = "$out/${target}"; - installFile = let - type = lib.filesystem.pathType v.source; + build.extraSetup = + let + installFiles = + acc: n: v: + let + source = lib.escapeShellArg v.source; + target = lib.escapeShellArg v.target; + target' = "$out/${target}"; + installFile = + let + type = lib.filesystem.pathType v.source; + in + if type == "directory" then + '' + mkdir -p $(basename ${target'}) && cp --recursive ${source} ${target'} + '' + else if type == "symlink" then + '' + ln --symbolic --force ${source} ${target'} + '' + else + '' + install -D --mode=${v.mode} ${source} ${target'} + ''; in - if type == "directory" then '' - mkdir -p $(basename ${target'}) && cp --recursive ${source} ${target'} - '' else if type == "symlink" then '' - ln --symbolic --force ${source} ${target'} - '' else '' - install -D --mode=${v.mode} ${source} ${target'} + '' + ${acc} + ${installFile} ''; - in '' - ${acc} - ${installFile} + in + lib.mkBefore '' + ${lib.foldlAttrs installFiles "" cfg} ''; - in lib.mkBefore '' - ${lib.foldlAttrs installFiles "" cfg} - ''; }; } diff --git a/tests/configs/lib-modules-subset/make-wraparound.nix b/tests/configs/lib-modules-subset/make-wraparound.nix index 4ba00c7..9a6b23a 100644 --- a/tests/configs/lib-modules-subset/make-wraparound.nix +++ b/tests/configs/lib-modules-subset/make-wraparound.nix @@ -1,4 +1,10 @@ -{ config, lib, pkgs, wrapperManagerLib, ... }: +{ + config, + lib, + pkgs, + wrapperManagerLib, + ... +}: let inherit (wrapperManagerLib) makeWraparound; @@ -7,7 +13,10 @@ in build.variant = "shell"; wrappers.tmux = makeWraparound { under = lib.getExe' pkgs.boxxy "boxxy"; - underFlags = [ "--rule" "~/.tmux.conf:~/.config/tmux/tmux.conf" ]; + underFlags = [ + "--rule" + "~/.tmux.conf:~/.config/tmux/tmux.conf" + ]; underSeparator = "--"; arg0 = lib.getExe' pkgs.tmux "tmux"; diff --git a/tests/configs/neofetch-with-additional-files.nix b/tests/configs/neofetch-with-additional-files.nix index 91dd953..2ce5506 100644 --- a/tests/configs/neofetch-with-additional-files.nix +++ b/tests/configs/neofetch-with-additional-files.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { wrappers.neofetch = { diff --git a/tests/configs/single-basepackage.nix b/tests/configs/single-basepackage.nix index 7d2aac0..418d0c5 100644 --- a/tests/configs/single-basepackage.nix +++ b/tests/configs/single-basepackage.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { basePackages = pkgs.fastfetch; diff --git a/tests/configs/wrapper-fastfetch.nix b/tests/configs/wrapper-fastfetch.nix index 9980853..1d5a783 100644 --- a/tests/configs/wrapper-fastfetch.nix +++ b/tests/configs/wrapper-fastfetch.nix @@ -19,9 +19,12 @@ xdg.desktopEntry.enable = true; }; - environment.pathAdd = wrapperManagerLib.getBin (with pkgs; [ - hello - ]); + environment.pathAdd = wrapperManagerLib.getBin ( + with pkgs; + [ + hello + ] + ); build.extraPassthru.wrapperManagerTests = { actuallyBuilt = diff --git a/tests/configs/xdg-basedirs.nix b/tests/configs/xdg-basedirs.nix index 3733b28..ded2b7d 100644 --- a/tests/configs/xdg-basedirs.nix +++ b/tests/configs/xdg-basedirs.nix @@ -22,19 +22,23 @@ ); wrappers.xdg-config-dirs-script = { - arg0 = let - app = pkgs.writeShellScript "xdg-dirs-script" '' - echo "$XDG_CONFIG_DIRS" | tr ':' '\n' - ''; - in builtins.toString app; + arg0 = + let + app = pkgs.writeShellScript "xdg-dirs-script" '' + echo "$XDG_CONFIG_DIRS" | tr ':' '\n' + ''; + in + builtins.toString app; }; wrappers.xdg-data-dirs-script = { - arg0 = let - app = pkgs.writeShellScript "xdg-dirs-script" '' - echo "$XDG_DATA_DIRS" | tr ':' '\n' - ''; - in builtins.toString app; + arg0 = + let + app = pkgs.writeShellScript "xdg-dirs-script" '' + echo "$XDG_DATA_DIRS" | tr ':' '\n' + ''; + in + builtins.toString app; }; build.extraPassthru.wrapperManagerTests = { diff --git a/tests/default.nix b/tests/default.nix index f23bc47..5c50b16 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -10,10 +10,13 @@ let inherit (pkgs) lib; in { - configs = let - configs' = import ./configs { inherit pkgs; }; - updateTestName = configName: package: lib.mapAttrs' (n: v: lib.nameValuePair "${configName}-${n}" v) package.wrapperManagerTests; - in + configs = + let + configs' = import ./configs { inherit pkgs; }; + updateTestName = + configName: package: + lib.mapAttrs' (n: v: lib.nameValuePair "${configName}-${n}" v) package.wrapperManagerTests; + in lib.concatMapAttrs updateTestName configs'; lib =