-
Notifications
You must be signed in to change notification settings - Fork 47
/
flake.nix
144 lines (122 loc) · 4.19 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
{
description = "A simple Go package";
# Nixpkgs / NixOS version to use.
inputs = {
nixpkgs = {
url = "github:Nixos/nixpkgs/nixpkgs-unstable";
flake = true;
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, flake-compat }:
let
# to work with older version of flakes
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
# Generate a user-friendly version number.
version = builtins.substring 0 8 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; });
in
{
# Provide some binary packages for selected system types.
packages = forAllSystems
(system:
let
pkgs = nixpkgsFor.${system};
name = "Seekr";
appdir = "${name}.AppDir";
in
{
seekr-appimage = pkgs.stdenv.mkDerivation {
name = "seekr-appimage";
#src = self.packages.${system}.seekr;
src = ./.;
buildInputs = [
pkgs.appimagekit
self.packages.${system}.seekr
];
buildPhase = ''
mkdir -p ${appdir}/usr/bin
cp web/images/256x256.png ${appdir}/${name}.png
install ${self.packages.${system}.seekr}/bin/seekr ${appdir}/usr/bin/seekr
cat > ${appdir}/${name}.desktop <<EOF
[Desktop Entry]
Type=Application
Name=Seekr
Exec=seekr %U
Icon=Seekr
StartupNotify=true
Categories=Network;
EOF
cp AppRun ${appdir}/AppRun
chmod +x ${appdir}/AppRun
appimagetool -v -n ./Seekr.AppDir ./Seekr.AppImage
appimagetool -l ./Seekr.AppImage
'';
installPhase = ''
mkdir -p $out/bin
cp -r ${appdir} $out/${appdir}
install Seekr.AppImage $out/Seekr.AppImage
'';
};
seekr = pkgs.buildGoModule {
#${pkgs.git}/bin/git init -q
postConfigure = ''
${pkgs.go}/bin/go generate ./...
${pkgs.nodePackages_latest.typescript}/bin/tsc --project web --watch false
'';
pname = "seekr";
inherit version;
src = ./.;
CGO_ENABLED = 0;
tags = [
"osusergo"
"netgo"
"static_build"
];
ldflags = [
"-s -w"
"-extldflags=-static"
#"-X main.version=${version}"
];
vendorSha256 = "sha256-MNwGL+G8/y/TK1zDJd6OffFExbH2QGPCix6ktnYaELc=";
};
});
apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.seekr}/bin/seekr";
};
});
formatter = forAllSystems (system: nixpkgsFor.${system}.nixpkgs-fmt);
devShells = forAllSystems (system: {
default = nixpkgsFor.${system}.mkShell {
packages = [
nixpkgsFor.${system}.nodePackages_latest.typescript
nixpkgsFor.${system}.go
nixpkgsFor.${system}.gcc
# jq is useful to debug the database
nixpkgsFor.${system}.jq
nixpkgsFor.${system}.gh
nixpkgsFor.${system}.goreleaser
nixpkgsFor.${system}.gcc
];
};
shellHook = ''
sbuild() {
go generate ./...
tsc --project web
go run main.go
}
'';
});
defaultPackage = forAllSystems (system: self.packages.${system}.seekr);
};
}