This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
forked from fufexan/webcord-flake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
86 lines (76 loc) · 2.2 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
description = "WebCord Nix Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
dream2nix = {
url = "github:nix-community/dream2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
webcord = {
url = "github:SpacingBat3/WebCord";
flake = false;
};
};
outputs = {
self,
nixpkgs,
dream2nix,
webcord,
...
}: let
inherit (nixpkgs) lib;
supportedSystems = [
"aarch64-linux"
"x86_64-linux"
# open an issue if you want these
#"aarch64-darwin"
#"x86_64-darwin"
];
genSystems = lib.genAttrs supportedSystems;
dreamlib = genSystems (system:
dream2nix.lib.init {
pkgs = nixpkgs.legacyPackages.${system};
config = {
projectRoot = ./.;
overridesDirs = ["${dream2nix}/overrides" ./overrides];
};
});
dream = genSystems (system: dreamlib.${system}.makeOutputs {source = webcord;});
wrapper = system: old: config: let
pkgs = nixpkgs.legacyPackages.${system};
webcord-wrapped =
pkgs.runCommand "${old.name}-wrapped"
{
inherit (old) pname version meta;
nativeBuildInputs = [pkgs.makeWrapper];
makeWrapperArgs = config.makeWrapperArgs or [];
}
''
mkdir -p $out
cp -r --no-preserve=mode,ownership ${old}/* $out/
chmod +x $out/bin/*
wrapProgram "$out/bin/webcord" ''${makeWrapperArgs[@]} ${
lib.optionalString ((config.flags or []) != [])
(lib.concatStringsSep " " (map (flag: "--add-flags ${flag}") config.flags))
}
'';
in
webcord-wrapped // {override = wrapper system old;};
in {
packages = genSystems (system: {
webcord = wrapper system dream.${system}.packages.webcord {};
default = self.packages.${system}.webcord;
});
homeManagerModules = {
webcord = import ./hm-module.nix self;
default = self.homeManagerModules.webcord;
};
overlays = {
webcord = _: prev: {
webcord = self.packages.${prev.system}.webcord;
};
default = self.overlays.webcord;
};
formatter = genSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
};
}