get rid of niv

This commit is contained in:
Jörg Thalheim 2022-04-10 22:08:57 +02:00
parent 9c29a82b46
commit 4f6b7a6d04
No known key found for this signature in database
10 changed files with 32 additions and 306 deletions

View file

@ -2,7 +2,6 @@
{
imports = [
./nixpkgs-update.nix
../roles/common.nix
../roles/hardware/hetzner-amd.nix
../roles/hetzner-network.nix

View file

@ -1,11 +1,12 @@
{ nixpkgs-update
, nixpkgs-update-github-releases
, nixpkgs-update-pypi-releases
}:
{ pkgs, lib, config, ... }:
let
userLib = import ../users/lib.nix { inherit lib; };
sources = import ../nix/sources.nix;
nixpkgs-update = import sources.nixpkgs-update { };
nixpkgs-update-bin = "${nixpkgs-update}/bin/nixpkgs-update";
nixpkgs-update-bin = "${nixpkgs-update.defaultPackage.${pkgs.system}}/bin/nixpkgs-update";
nixpkgsUpdateSystemDependencies = with pkgs; [
nix # for nix-shell used by python packges to update fetchers
@ -17,8 +18,8 @@ let
cachix
];
nixpkgs-update-github-releases = "${sources.nixpkgs-update-github-releases}/main.py";
nixpkgs-update-pypi-releases = "${sources.nixpkgs-update-pypi-releases}/main.py";
nixpkgs-update-github-releases' = "${nixpkgs-update-github-releases}/main.py";
nixpkgs-update-pypi-releases' = "${nixpkgs-update-pypi-releases}/main.py";
mkNixpkgsUpdateService = name: {
description = "nixpkgs-update ${name} service";
@ -79,7 +80,7 @@ in
systemd.services.nixpkgs-update-github = mkNixpkgsUpdateService "github" // {
script = ''
${nixpkgs-update-bin} delete-done --delete
${nixpkgs-update-github-releases} > /var/lib/nixpkgs-update/github/packages-to-update.txt
${nixpkgs-update-github-releases'} > /var/lib/nixpkgs-update/github/packages-to-update.txt
${nixpkgs-update-command}
'';
};
@ -88,7 +89,7 @@ in
script = ''
${nixpkgs-update-bin} delete-done --delete
grep -rl $XDG_CACHE_HOME/nixpkgs -e buildPython | grep default | \
${nixpkgs-update-pypi-releases} --nixpkgs=/var/cache/nixpkgs-update/pypi/nixpkgs > /var/lib/nixpkgs-update/pypi/packages-to-update.txt
${nixpkgs-update-pypi-releases'} --nixpkgs=/var/cache/nixpkgs-update/pypi/nixpkgs > /var/lib/nixpkgs-update/pypi/packages-to-update.txt
${nixpkgs-update-command}
'';
};

View file

@ -20,7 +20,6 @@
../services/hound
../services/hydra
../services/marvin-mk2.nix
../services/matterbridge.nix
];

View file

@ -29,31 +29,44 @@
in pkgs.callPackage ./shell.nix {
inherit (sops-nix.packages.x86_64-linux) sops-import-keys-hook;
};
nixosConfigurations = {
nixosConfigurations = let
common = [
sops-nix.nixosModules.sops
];
in {
build01 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
modules = common ++ [
./build01/configuration.nix
];
};
build02 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
modules = common ++ [
(import ./build02/nixpkgs-update.nix {
inherit nixpkgs-update
nixpkgs-update-github-releases
nixpkgs-update-pypi-releases;
})
./build02/configuration.nix
];
};
build03 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
modules = common ++ [
(import ./services/marvin-mk2.nix {
inherit marvin-mk2;
})
./build03/configuration.nix
];
};
build04 = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
modules = common ++ [
./build04/configuration.nix
];
};

View file

@ -1,11 +0,0 @@
{ system ? builtins.currentSystem }:
let
sources = import ./sources.nix;
pkgs = import sources.nixpkgs {
inherit system;
config = { };
overlays = import ./overlays.nix;
};
in
pkgs

View file

@ -1,98 +0,0 @@
{
"hercules-ci-effects": {
"branch": "master",
"description": "Expressions to change the world",
"homepage": null,
"owner": "hercules-ci",
"repo": "hercules-ci-effects",
"rev": "14dcd541e4d5315deb3f6941cd5b293945c14584",
"sha256": "1jp27s9vzp4pdnam0qdhmg7dl3m9pfdywab2sdw7pw3z38id4kz9",
"type": "tarball",
"url": "https://github.com/hercules-ci/hercules-ci-effects/archive/14dcd541e4d5315deb3f6941cd5b293945c14584.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"marvin-mk2": {
"branch": "master",
"description": "Helpful nixpkgs PR bot with an improved Genuine People Personality",
"homepage": "https://github.com/timokau/marvin-mk2",
"owner": "timokau",
"repo": "marvin-mk2",
"rev": "b3dd8c02a5c01dcf0e9cc8789846a0ec980f534b",
"sha256": "0fyjygyk69zjvcvqzn15d3b2akaksx802f7x4r7f0k6skywi1zm4",
"type": "tarball",
"url": "https://github.com/timokau/marvin-mk2/archive/b3dd8c02a5c01dcf0e9cc8789846a0ec980f534b.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-unstable-small",
"description": "Nix Packages collection",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3c745c05fb1d0979af3c6db7dc8c12d35c7e41e0",
"sha256": "1p7p93mwaf1im82lva2j7kvl318f5668khza0g4drz70zbjirpkf",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/3c745c05fb1d0979af3c6db7dc8c12d35c7e41e0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-update": {
"branch": "main",
"description": "Semi-automatically updating nixpkgs packages since 2018",
"homepage": "",
"owner": "ryantm",
"repo": "nixpkgs-update",
"rev": "43d2113dbf50c4516328fa181e5f35facb719e63",
"sha256": "0m2y9w042lngmwdykbw1w7kqlpms8wmz7py1ckavc9f53jnhgdjb",
"type": "tarball",
"url": "https://github.com/ryantm/nixpkgs-update/archive/43d2113dbf50c4516328fa181e5f35facb719e63.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-update-github-releases": {
"branch": "master",
"description": "Fetches releases from github for ryantm/nixpkgs-update",
"homepage": null,
"owner": "ryantm",
"repo": "nixpkgs-update-github-releases",
"rev": "e31b003d8edd400d06b718c717c19532585389f9",
"sha256": "0s1ldxdqbx0vx2prwh7k7b3kqgj6wzjyawz4wl98yfgi41wxd0h4",
"type": "tarball",
"url": "https://github.com/ryantm/nixpkgs-update-github-releases/archive/e31b003d8edd400d06b718c717c19532585389f9.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-update-pypi-releases": {
"branch": "master",
"description": "Fetches releases from pypi for https://github.com/ryantm/nixpkgs-update",
"homepage": null,
"owner": "ryantm",
"repo": "nixpkgs-update-pypi-releases",
"rev": "56afe60a7fd7ee7f5dac5feeea8a983aba759997",
"sha256": "00y2wbbdnlm5b05vnns6bf482zh3s0hsb9jd9k4d31w17f0qkh19",
"type": "tarball",
"url": "https://github.com/ryantm/nixpkgs-update-pypi-releases/archive/56afe60a7fd7ee7f5dac5feeea8a983aba759997.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"simple-hydra": {
"branch": "master",
"description": "A simple module for enabling Hydra",
"homepage": null,
"owner": "ElvishJerricco",
"repo": "simple-hydra",
"rev": "0d28b0b66136082d0cbfd90ede4436a580e3e8d0",
"sha256": "0x5x047cb3i5pvic6gb3xid7dkx3sg535rfrrrgiapny3291pkma",
"type": "tarball",
"url": "https://github.com/ElvishJerricco/simple-hydra/archive/0d28b0b66136082d0cbfd90ede4436a580e3e8d0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"sops-nix": {
"branch": "master",
"description": "Atomic secret provisioning for NixOS based on sops",
"homepage": "",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "c01f48b055ac776f9831c9d4a0fff83e3b74dbe3",
"sha256": "0aqhh2c8hnsm5jr7jvajvcsc2l90iv33d11nf8jk3ybxm0qxzhb6",
"type": "tarball",
"url": "https://github.com/Mic92/sops-nix/archive/c01f48b055ac776f9831c9d4a0fff83e3b74dbe3.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

View file

@ -1,172 +0,0 @@
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
fetch_tarball = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
fetch_git = name: spec:
let
ref =
if spec ? ref then spec.ref else
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
in
builtins.fetchGit { url = spec.repo; inherit (spec) rev;inherit ref; };
fetch_local = spec: spec.path;
fetch_builtin-tarball = name: throw
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=tarball -a builtin=true'';
fetch_builtin-url = name: throw
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=file -a builtin=true'';
#
# Various helpers
#
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
sanitizeName = name:
(
concatMapStrings (s: if builtins.isList s then "-" else s)
(
builtins.split "[^[:alnum:]+._?=-]+"
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
)
);
# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources: system:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> { }
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs name spec
else if spec.type == "tarball" then fetch_tarball pkgs name spec
else if spec.type == "git" then fetch_git name spec
else if spec.type == "local" then fetch_local spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
else if spec.type == "builtin-url" then fetch_builtin-url name
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# If the environment variable NIV_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
replace = name: drv:
let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in
if ersatz == "" then drv else ersatz;
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or (
f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else { };
# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs
(
name: spec:
if builtins.hasAttr "outPath" spec
then
abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
)
config.sources;
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile)
, system ? builtins.currentSystem
, pkgs ? mkPkgs sources system
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs;
};
in
mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }

View file

@ -1,10 +1,8 @@
{ config, lib, pkgs, ... }:
let
sources = import ../nix/sources.nix;
hostDir = lib.head (builtins.match "nix-community-(.*)" config.networking.hostName);
defaultSopsPath = ../. + "/${hostDir}/secrets.yaml";
in
{
imports = [ "${sources.sops-nix}/modules/sops" ];
sops.defaultSopsFile = lib.mkIf (builtins.pathExists defaultSopsPath) defaultSopsPath;
}

View file

@ -1,16 +1,14 @@
{ marvin-mk2 }:
{ pkgs, lib, config, ... }:
let
userLib = import ../users/lib.nix { inherit lib; };
sources = import ../nix/sources.nix;
marvinNixpkgs = (import (sources.marvin-mk2.outPath + "/definitions.nix") { }).pkgs;
marvin-mk2 = marvinNixpkgs.python3.pkgs.buildPythonApplication rec {
marvin-mk2' = pkgs.python3.pkgs.buildPythonApplication rec {
pname = "marvin-mk2";
version = "rolling";
src = sources.marvin-mk2;
src = marvin-mk2;
propagatedBuildInputs = with marvinNixpkgs.python3.pkgs; [
propagatedBuildInputs = with pkgs.python3.pkgs; [
aiohttp
gidgethub
];
@ -52,7 +50,7 @@ in
description = "marvin-mk2 service";
enable = true;
path = [
marvin-mk2
marvin-mk2'
];
environment.BOT_NAME = "marvin-mk2";
environment.PORT = "3001";

View file

@ -10,7 +10,6 @@ mkShell {
buildInputs = with pkgs; [
git-crypt
niv
terraform
(terraform.withPlugins (
p: [