Created
June 14, 2024 22:26
-
-
Save ibizaman/3d577f506d359ca47e222fe5e1e8b1f3 to your computer and use it in GitHub Desktop.
Module to extract files to a destination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ... }: | |
let | |
extract = { source, stdenv }: | |
stdenv.mkDerivation { | |
# inherit destination; | |
name = "extract"; | |
version = "1.0"; | |
src = source; | |
# builder = '' | |
# source $stdenv/setup | |
# installPhase() { | |
# mkdir -p $out | |
# cp foo $out | |
# } | |
# genericBuild | |
# ''; | |
}; | |
extractModule = { | |
options = { | |
source = lib.mkOption { | |
description = "Source Archive"; | |
type = lib.types.path; | |
}; | |
destination = lib.mkOption { | |
description = "Destination Folder"; | |
type = lib.types.str; | |
}; | |
}; | |
}; | |
cfg = config.test.extract; | |
in | |
{ | |
options.test = { | |
extract = lib.mkOption { | |
type = lib.types.attrsOf ( lib.types.submodule extractModule ); | |
}; | |
}; | |
config = { | |
home.file = lib.mapAttrs' (name: config: lib.nameValuePair (config.destination + "/" + name) { | |
source = pkgs.callPackage extract { inherit (config) source; }; | |
}) cfg; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
home-manager.users.me = { | |
imports = [ | |
./test.nix | |
]; | |
test.extract.mytheme = { | |
source = ../archive.xz; | |
destination = "./local"; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment