Skip to content

Commit 8d0d16e

Browse files
authored
Merge pull request #188 from nix-community/feat/remove-gomod2nix
feat/remove gomod2nix
2 parents 5f81bb8 + 37a7da8 commit 8d0d16e

File tree

8 files changed

+83
-116
lines changed

8 files changed

+83
-116
lines changed

flake.lock

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
inputs.nixpkgs.follows = "nixpkgs";
99
inputs.systems.follows = "systems";
1010
};
11-
gomod2nix = {
12-
url = "github:nix-community/gomod2nix";
13-
inputs.nixpkgs.follows = "nixpkgs";
14-
inputs.flake-utils.follows = "flake-utils";
15-
};
1611
systems.url = "github:nix-systems/default";
1712
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
1813
flake-utils.url = "github:numtide/flake-utils";
@@ -35,7 +30,6 @@
3530
godoc.inputs.blueprint.follows = "blueprint";
3631
godoc.inputs.treefmt-nix.follows = "treefmt-nix";
3732
godoc.inputs.flake-utils.follows = "flake-utils";
38-
godoc.inputs.gomod2nix.follows = "gomod2nix";
3933
};
4034

4135
# Keep the magic invocations to minimum.

go.mod

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
module github.com/numtide/nixos-facter
22

3-
go 1.22.3
3+
go 1.24.1
44

5-
require (
6-
github.com/klauspost/cpuid/v2 v2.2.9
7-
github.com/stretchr/testify v1.10.0
8-
)
5+
require github.com/stretchr/testify v1.10.0
96

107
require (
118
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
129
github.com/kr/pretty v0.3.1 // indirect
1310
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
14-
golang.org/x/sys v0.22.0 // indirect
1511
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
1612
gopkg.in/yaml.v3 v3.0.1 // indirect
1713
)

go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
22
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
33
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/klauspost/cpuid/v2 v2.2.9-0.20240805145549-92d5326f011e h1:XLeT7xVis8xyC0F4CqQ2fAcuBar61PMI7GhrUEBBKas=
5-
github.com/klauspost/cpuid/v2 v2.2.9-0.20240805145549-92d5326f011e/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
6-
github.com/klauspost/cpuid/v2 v2.2.9-0.20241026200132-ee7cba987ff4 h1:veWv2fzhVgC4iQ4ZRlXLwq68XWBJfDdk6FuklLmgVUI=
7-
github.com/klauspost/cpuid/v2 v2.2.9-0.20241026200132-ee7cba987ff4/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
8-
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
94
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
105
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
116
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -15,12 +10,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
1510
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1611
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
1712
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
18-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
19-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
2013
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
2114
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
22-
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
23-
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2415
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2516
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
2617
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

nix/devshells/default.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
...
55
}:
66
perSystem.self.nixos-facter.overrideAttrs (old: {
7-
GOROOT = "${old.go}/share/go";
7+
GOROOT = "${old.passthru.go}/share/go";
88
nativeBuildInputs =
99
old.nativeBuildInputs
1010
++ [
11-
perSystem.gomod2nix.default
1211
pkgs.enumer
1312
pkgs.delve
1413
pkgs.pprof

nix/packages/nixos-facter/default.nix

Lines changed: 12 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,26 @@
1-
{
2-
flake,
1+
args @ {
32
# We need the following pragma to ensure deadnix doesn't remove inputs.
43
# This package is being called with newScope/callPackage, which means it is only being passed args it defines.
54
# We do not use inputs directly in this file, but need it for passing to the tests.
5+
flake,
66
# deadnix: skip
77
inputs,
8-
perSystem,
8+
# deadnix: skip
99
system,
10+
perSystem,
1011
pkgs,
11-
pname,
1212
...
13-
} @ args: let
14-
inherit (pkgs) go lib;
15-
fs = lib.fileset;
13+
}: let
14+
inherit (pkgs) lib;
1615
in
17-
perSystem.gomod2nix.buildGoApplication rec {
18-
inherit pname;
16+
pkgs.callPackage ./package.nix {
17+
hwinfo = perSystem.hwinfo.default;
18+
1919
# there's no good way of tying in the version to a git tag or branch
2020
# so for simplicity's sake we set the version as the commit revision hash
2121
# we remove the `-dirty` suffix to avoid a lot of unnecessary rebuilds in local dev
2222
version = lib.removeSuffix "-dirty" (flake.shortRev or flake.dirtyShortRev);
23-
24-
# ensure we are using the same version of go to build with
25-
inherit go;
26-
27-
src = fs.toSource {
28-
root = ../../..;
29-
fileset = fs.unions [
30-
../../../cmd
31-
../../../go.mod
32-
../../../go.sum
33-
../../../main.go
34-
../../../pkg
35-
];
36-
};
37-
38-
modules = ./gomod2nix.toml;
39-
40-
buildInputs = [
41-
pkgs.systemdMinimal.dev
42-
perSystem.hwinfo.default
43-
];
44-
45-
nativeBuildInputs = with pkgs; [
46-
gcc
47-
makeWrapper
48-
pkg-config
49-
];
50-
51-
ldflags = [
52-
"-s"
53-
"-w"
54-
"-X github.com/numtide/nixos-facter/pkg/build.Name=${pname}"
55-
"-X github.com/numtide/nixos-facter/pkg/build.Version=v${version}"
56-
"-X github.com/numtide/nixos-facter/pkg/build.System=${pkgs.stdenv.hostPlatform.system}"
57-
];
58-
59-
postInstall = let
60-
binPath = lib.makeBinPath (with pkgs; [
61-
systemdMinimal
62-
]);
63-
in ''
64-
wrapProgram "$out/bin/nixos-facter" \
65-
--prefix PATH : "${binPath}"
66-
'';
67-
68-
passthru.tests = (import ./tests) args;
69-
70-
meta = with lib; {
71-
description = "nixos-facter: declarative nixos-generate-config";
72-
homepage = "https://github.com/numtide/nixos-facter";
73-
license = licenses.mit;
74-
mainProgram = "nixos-facter";
75-
};
23+
}
24+
// {
25+
passthru.tests = import ./tests args;
7626
}

nix/packages/nixos-facter/gomod2nix.toml

Lines changed: 0 additions & 27 deletions
This file was deleted.

nix/packages/nixos-facter/package.nix

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
lib,
3+
version ? "0.3.1",
4+
systemdMinimal,
5+
hwinfo,
6+
gcc,
7+
makeWrapper,
8+
pkg-config,
9+
stdenv,
10+
buildGo124Module,
11+
}: let
12+
fs = lib.fileset;
13+
in
14+
buildGo124Module (final: {
15+
pname = "nixos-facter";
16+
inherit version;
17+
18+
src = fs.toSource {
19+
root = ../../..;
20+
fileset = fs.unions [
21+
../../../cmd
22+
../../../go.mod
23+
../../../go.sum
24+
../../../main.go
25+
../../../pkg
26+
];
27+
};
28+
29+
vendorHash = "sha256-A7ZuY8Gc/a0Y8O6UG2WHWxptHstJOxi4n9F8TY6zqiw=";
30+
31+
buildInputs = [
32+
systemdMinimal.dev
33+
hwinfo
34+
];
35+
36+
nativeBuildInputs = [
37+
gcc
38+
makeWrapper
39+
pkg-config
40+
];
41+
42+
ldflags = [
43+
"-s"
44+
"-w"
45+
"-X github.com/numtide/nixos-facter/pkg/build.Name=${final.pname}"
46+
"-X github.com/numtide/nixos-facter/pkg/build.Version=v${final.version}"
47+
"-X github.com/numtide/nixos-facter/pkg/build.System=${stdenv.hostPlatform.system}"
48+
];
49+
50+
postInstall = let
51+
binPath = lib.makeBinPath [
52+
systemdMinimal
53+
];
54+
in ''
55+
wrapProgram "$out/bin/nixos-facter" \
56+
--prefix PATH : "${binPath}"
57+
'';
58+
59+
meta = with lib; {
60+
description = "nixos-facter: declarative nixos-generate-config";
61+
homepage = "https://github.com/numtide/nixos-facter";
62+
license = licenses.mit;
63+
mainProgram = "nixos-facter";
64+
};
65+
})

0 commit comments

Comments
 (0)