Skip to content

Instantly share code, notes, and snippets.

@ibizaman
Created June 14, 2024 22:26
Show Gist options
  • Save ibizaman/3d577f506d359ca47e222fe5e1e8b1f3 to your computer and use it in GitHub Desktop.
Save ibizaman/3d577f506d359ca47e222fe5e1e8b1f3 to your computer and use it in GitHub Desktop.
Module to extract files to a destination
{ 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;
};
}
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