mirror of https://github.com/go-gitea/gitea.git
Browse Source
`flake-utils` is currently only used for outputting system-specific dev shells. This can actually be achieved only using functionality already present within `nixpkgs`, thus there is no need for an extra dependency. Additionally, we move to use the `packages` and `env` args for `mkShell` to more clearly outline what they are used for. --- Further reading: https://determinate.systems/blog/best-practices-for-nix-at-work/#avoid-flake-helper-libraries-if-possible As a side note, using `with` to import large scopes is [discouraged by official Nix resources](https://nix.dev/guides/best-practices#with-scopes), so an alternative approach to list installed packages could be something like this: ```nix packages = (builtins.attrValues { inherit (pkgs) # generic git git-lfs gnumake gnused gnutar gzip zip # frontend cairo pixman pkg-config # linting uv # backend gofumpt sqlite ; inherit # frontend nodejs pnpm # linting python3 # backend go ; }) ++ linuxOnlyInputs; ``` But I saw this as too pedantic to include in the initial PR. Co-authored-by: 6543 <6543@obermui.de>pull/35865/head
2 changed files with 80 additions and 93 deletions
@ -1,73 +1,94 @@ |
|||||||
{ |
{ |
||||||
inputs = { |
inputs = { |
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; |
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; |
||||||
flake-utils.url = "github:numtide/flake-utils"; |
|
||||||
}; |
}; |
||||||
outputs = |
outputs = |
||||||
{ nixpkgs, flake-utils, ... }: |
{ nixpkgs, ... }: |
||||||
flake-utils.lib.eachDefaultSystem ( |
let |
||||||
system: |
supportedSystems = [ |
||||||
let |
"aarch64-darwin" |
||||||
pkgs = nixpkgs.legacyPackages.${system}; |
"aarch64-linux" |
||||||
in |
"x86_64-darwin" |
||||||
{ |
"x86_64-linux" |
||||||
devShells.default = |
]; |
||||||
with pkgs; |
|
||||||
let |
|
||||||
# only bump toolchain versions here |
|
||||||
go = go_1_25; |
|
||||||
nodejs = nodejs_24; |
|
||||||
python3 = python312; |
|
||||||
pnpm = pnpm_10; |
|
||||||
|
|
||||||
# Platform-specific dependencies |
|
||||||
linuxOnlyInputs = lib.optionals pkgs.stdenv.isLinux [ |
|
||||||
glibc.static |
|
||||||
]; |
|
||||||
|
|
||||||
linuxOnlyEnv = lib.optionalAttrs pkgs.stdenv.isLinux { |
forEachSupportedSystem = |
||||||
CFLAGS = "-I${glibc.static.dev}/include"; |
f: |
||||||
LDFLAGS = "-L ${glibc.static}/lib"; |
nixpkgs.lib.genAttrs supportedSystems ( |
||||||
|
system: |
||||||
|
let |
||||||
|
pkgs = import nixpkgs { |
||||||
|
inherit system; |
||||||
}; |
}; |
||||||
in |
in |
||||||
pkgs.mkShell ( |
f { inherit pkgs; } |
||||||
{ |
); |
||||||
buildInputs = [ |
in |
||||||
# generic |
{ |
||||||
git |
devShells = forEachSupportedSystem ( |
||||||
git-lfs |
{ pkgs, ... }: |
||||||
gnumake |
{ |
||||||
gnused |
default = |
||||||
gnutar |
let |
||||||
gzip |
inherit (pkgs) lib; |
||||||
zip |
|
||||||
|
# only bump toolchain versions here |
||||||
|
go = pkgs.go_1_25; |
||||||
|
nodejs = pkgs.nodejs_24; |
||||||
|
python3 = pkgs.python312; |
||||||
|
pnpm = pkgs.pnpm_10; |
||||||
|
|
||||||
# frontend |
# Platform-specific dependencies |
||||||
nodejs |
linuxOnlyInputs = lib.optionals pkgs.stdenv.isLinux [ |
||||||
pnpm |
pkgs.glibc.static |
||||||
cairo |
]; |
||||||
pixman |
|
||||||
pkg-config |
|
||||||
|
|
||||||
# linting |
linuxOnlyEnv = lib.optionalAttrs pkgs.stdenv.isLinux { |
||||||
python3 |
CFLAGS = "-I${pkgs.glibc.static.dev}/include"; |
||||||
uv |
LDFLAGS = "-L ${pkgs.glibc.static}/lib"; |
||||||
|
}; |
||||||
|
in |
||||||
|
pkgs.mkShell { |
||||||
|
packages = |
||||||
|
with pkgs; |
||||||
|
[ |
||||||
|
# generic |
||||||
|
git |
||||||
|
git-lfs |
||||||
|
gnumake |
||||||
|
gnused |
||||||
|
gnutar |
||||||
|
gzip |
||||||
|
zip |
||||||
|
|
||||||
# backend |
# frontend |
||||||
go |
nodejs |
||||||
gofumpt |
pnpm |
||||||
sqlite |
cairo |
||||||
] |
pixman |
||||||
++ linuxOnlyInputs; |
pkg-config |
||||||
|
|
||||||
GO = "${go}/bin/go"; |
# linting |
||||||
GOROOT = "${go}/share/go"; |
python3 |
||||||
|
uv |
||||||
|
|
||||||
TAGS = "sqlite sqlite_unlock_notify"; |
# backend |
||||||
STATIC = "true"; |
go |
||||||
} |
gofumpt |
||||||
// linuxOnlyEnv |
sqlite |
||||||
); |
] |
||||||
} |
++ linuxOnlyInputs; |
||||||
); |
|
||||||
|
env = { |
||||||
|
GO = "${go}/bin/go"; |
||||||
|
GOROOT = "${go}/share/go"; |
||||||
|
|
||||||
|
TAGS = "sqlite sqlite_unlock_notify"; |
||||||
|
STATIC = "true"; |
||||||
|
} |
||||||
|
// linuxOnlyEnv; |
||||||
|
}; |
||||||
|
} |
||||||
|
); |
||||||
|
}; |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue