-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
97 lines (84 loc) · 2.92 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
87
88
89
90
91
92
93
94
95
96
97
{
description = ''
Set of patches to the standard unsquashfs utility (part of
squashfs-tools) that attempts to add support for as many hacked-up
vendor-specific SquashFS implementations as possible
'';
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
# System types to support.
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = builtins.attrValues self.overlays; });
in
{
overlays.default = final: prev: {
sasquatch-le =
let
inherit (final) lib stdenv which zlib xz zstd lz4 lzo;
in
stdenv.mkDerivation {
pname = "sasquatch-le";
version = "4.5.1";
patches = lib.optionals final.stdenv.isDarwin
(final.fetchpatch {
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/ed81545df5083a95ddcfbff0c029774ecb0326bd/pkgs/tools/filesystems/squashfs/darwin.patch";
hash = "sha256-bSh9srb5WXD4KNCxALywdNMZcYQLFnrAzkTMRBnhXD8=";
});
src = ./.;
strictDeps = true;
nativeBuildInputs = [ which ];
buildInputs = [ zlib xz zstd lz4 lzo ];
preBuild = ''
cd squashfs-tools
'';
installFlags = [
"INSTALL_DIR=${placeholder "out"}/bin"
"INSTALL_MANPAGES_DIR=${placeholder "out"}/share/man/man1"
];
makeFlags = [
"GZIP_SUPPORT=1"
"XZ_SUPPORT=1"
"ZSTD_SUPPORT=1"
"LZ4_SUPPORT=1"
"LZMA_SUPPORT=1"
"LZO_SUPPORT=1"
];
};
sasquatch-be = final.sasquatch-le.overrideAttrs (super: {
pname = "sasquatch-be";
preConfigure = ''
export CFLAGS="-DFIX_BE"
'';
postInstall = ''
mv $out/bin/sasquatch{,-v4be}
'';
});
sasquatch = final.buildEnv {
name = "sasquatch";
paths = with final; [
sasquatch-be
sasquatch-le
];
};
};
packages = forAllSystems (system: rec {
inherit (nixpkgsFor.${system}) sasquatch sasquatch-be sasquatch-le;
default = sasquatch;
});
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
inputsFrom = [ pkgs.sasquatch-le ];
};
});
};
}