mirror of
https://github.com/gytis-ivaskevicius/flake-utils-plus.git
synced 2024-08-17 03:50:24 +03:00
Compare commits
15 Commits
2bf0f91643
...
bfc53579db
Author | SHA1 | Date | |
---|---|---|---|
|
bfc53579db | ||
|
5e1d2f3472 | ||
|
f726afcdf0 | ||
|
24b3a16053 | ||
|
f9d088fb6a | ||
|
339d9131ce | ||
|
724fbc3c84 | ||
|
1577ffa311 | ||
|
2db363d432 | ||
|
9d10d7ea17 | ||
|
170d7a3c78 | ||
|
2893fcad90 | ||
|
d01cae97e1 | ||
|
671cad9ada | ||
|
7a8d789d4d |
28
.github/workflows/ci.yaml
vendored
28
.github/workflows/ci.yaml
vendored
@ -1,4 +1,5 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
@ -6,16 +7,24 @@ on:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
eval:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v17
|
||||
with:
|
||||
install_url: https://github.com/numtide/nix-unstable-installer/releases/download/nix-2.8.0pre20220311_d532269/install
|
||||
- uses: actions/checkout@v4
|
||||
- uses: nixbuild/nix-quick-install-action@v25
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
# Quick eval
|
||||
- run: nix develop --command evalnix
|
||||
# Check formatting
|
||||
- run: nix develop --command fmt --check
|
||||
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: nixbuild/nix-quick-install-action@v25
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
# Execute /tests/*
|
||||
- run: nix develop --command check-derivation-outputs
|
||||
@ -23,6 +32,13 @@ jobs:
|
||||
- run: nix develop --command check-overlays-flow
|
||||
- run: nix develop --command check-hosts-config
|
||||
|
||||
build-examples:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: nixbuild/nix-quick-install-action@v25
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
# Build /examples/*
|
||||
- run: nix develop --command build-home-manager+nur+neovim-Rick
|
||||
- run: nix develop --command build-minimal-multichannel-Hostname1
|
||||
@ -30,5 +46,3 @@ jobs:
|
||||
- run: nix develop --command build-exporters-Morty
|
||||
- run: nix develop --command build-darwin
|
||||
|
||||
# Check formatting
|
||||
- run: nix develop --command fmt --check
|
||||
|
@ -1,17 +1,17 @@
|
||||
{ system ? builtins.currentSystem }:
|
||||
let
|
||||
# nixpkgs / devshell is only used for development. Don't add it to the flake.lock.
|
||||
nixpkgsGitRev = "1a268c42c8b0550f70da78c136171799481b0d97";
|
||||
devshellGitRev = "59fbe1dfc0de8c3332957c16998a7d16dff365d8";
|
||||
nixpkgsGitRev = "15de3b878a1fab784ddeae4c33cbc56381748505";
|
||||
devshellGitRev = "cd4e2fda3150dd2f689caeac07b7f47df5197c31";
|
||||
|
||||
nixpkgsSrc = fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsGitRev}.tar.gz";
|
||||
sha256 = "010d6glxdam0j7kah7h2z79fnqvgs703v6ac53v4hfv1iz7lvzv9";
|
||||
sha256 = "1nb53mycxj3hqcxg1vwbz76rkbmzkp84jgljqv6q2rby5v9k8cwc";
|
||||
};
|
||||
|
||||
devshellSrc = fetchTarball {
|
||||
url = "https://github.com/numtide/devshell/archive/${devshellGitRev}.tar.gz";
|
||||
sha256 = "0zsbgpssr704m8hbdmp5qnr86jv6s5h8jy8f35rlbpc2y0g5ka1d";
|
||||
sha256 = "02h3j2wqxsgf8sfl476q070ss86palxba48i497kh69nrvhqgz84";
|
||||
};
|
||||
|
||||
pkgs = import nixpkgsSrc { inherit system; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
description = "A highly awesome system configuration.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = github:nixos/nixpkgs/release-21.05;
|
||||
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable-small;
|
||||
utils.url = path:../../;
|
||||
darwin.url = "github:lnl7/nix-darwin/master";
|
||||
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
@ -2,7 +2,7 @@
|
||||
description = "FUP exporters demo";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = github:nixos/nixpkgs/release-21.05;
|
||||
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable-small; # Lets pretend that this is a stable channel
|
||||
unstable.url = github:nixos/nixpkgs/nixos-unstable-small;
|
||||
utils.url = path:../../;
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
};
|
||||
|
||||
home-manager = {
|
||||
url = github:nix-community/home-manager/release-21.05;
|
||||
url = github:nix-community/home-manager;
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
@ -2,8 +2,8 @@
|
||||
description = "A highly awesome system configuration.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = github:nixos/nixpkgs/release-21.05;
|
||||
unstable.url = github:nixos/nixpkgs/nixos-unstable;
|
||||
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable-small; # Lets pretend that this is a stable channel
|
||||
unstable.url = github:nixos/nixpkgs/nixos-unstable-small;
|
||||
utils.url = path:../../;
|
||||
};
|
||||
|
||||
|
24
flake.lock
24
flake.lock
@ -1,12 +1,15 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -19,6 +22,21 @@
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
@ -15,11 +15,16 @@
|
||||
exportPackages = import ./lib/exportPackages.nix fupArgs;
|
||||
genPkgOverlay = import ./lib/genPkgOverlay.nix;
|
||||
internal-functions = import ./lib/internal-functions.nix;
|
||||
overlay = import ./lib/overlay.nix;
|
||||
overlay = final: prev: {
|
||||
__dontExport = true;
|
||||
fup-repl = final.callPackage ./lib/fup-repl.nix { };
|
||||
};
|
||||
|
||||
in
|
||||
rec {
|
||||
inherit overlay;
|
||||
|
||||
blueprints.fup-repl = ./lib/fup-repl.nix;
|
||||
nixosModules.autoGenFromInputs = import ./lib/options.nix;
|
||||
darwinModules.autoGenFromInputs = import ./lib/options.nix;
|
||||
|
||||
|
20
lib/fup-repl.nix
Normal file
20
lib/fup-repl.nix
Normal file
@ -0,0 +1,20 @@
|
||||
{ writeShellScriptBin, coreutils, gnused }:
|
||||
let
|
||||
example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
|
||||
in
|
||||
writeShellScriptBin "repl" ''
|
||||
case "$1" in
|
||||
"-h"|"--help"|"help")
|
||||
printf "%b\n\e[4mUsage\e[0m: \
|
||||
${example "repl" "Loads system flake if available."} \
|
||||
${example "repl /path/to/flake.nix" "Loads specified flake."}\n"
|
||||
;;
|
||||
*)
|
||||
if [ -z "$1" ]; then
|
||||
nix repl ${./repl.nix}
|
||||
else
|
||||
nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') ${./repl.nix}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
''
|
@ -146,7 +146,6 @@ let
|
||||
|
||||
(if options ? nixpkgs.pkgs then
|
||||
{
|
||||
nixpkgs.config = selectedNixpkgs.config;
|
||||
nixpkgs.pkgs =
|
||||
# Make sure we don't import nixpkgs again if not
|
||||
# necessary. We can't use `config.nixpkgs.config`
|
||||
@ -205,7 +204,7 @@ mergeAny otherArguments (
|
||||
|
||||
# Little hack, we make sure that `legacyPackages` contains `nix` to make sure that we are dealing with nixpkgs.
|
||||
# For some odd reason `devshell` contains `legacyPackages` out put as well
|
||||
channelFlakes = filterAttrs (_: value: value ? legacyPackages && value.legacyPackages.x86_64-linux ? nix) inputs;
|
||||
channelFlakes = filterAttrs (_: value: value ? legacyPackages && value.legacyPackages ? x86_64-linux && value.legacyPackages.x86_64-linux ? nix) inputs;
|
||||
channelsFromFlakes = mapAttrs (name: input: { inherit input; }) channelFlakes;
|
||||
|
||||
importChannel = name: value: (import (patchChannel system value.input (value.patches or [ ])) {
|
||||
@ -236,8 +235,8 @@ mergeAny otherArguments (
|
||||
{ inherit pkgs; }
|
||||
// (foldl' mkOutputs { } (attrNames systemOutputs))
|
||||
)
|
||||
# produces attrset in the shape of
|
||||
# { nixosConfigurations = {}; darwinConfigurations = {}; ... }
|
||||
# according to profile.output or the default `nixosConfigurations`
|
||||
// foldl' mergeAny { } (attrValues (mapAttrs configurationBuilder hosts))
|
||||
# produces attrset in the shape of
|
||||
# { nixosConfigurations = {}; darwinConfigurations = {}; ... }
|
||||
# according to profile.output or the default `nixosConfigurations`
|
||||
// foldl' mergeAny { } (attrValues (mapAttrs configurationBuilder hosts))
|
||||
)
|
||||
|
@ -1,25 +0,0 @@
|
||||
final: prev:
|
||||
let
|
||||
example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
|
||||
in
|
||||
{
|
||||
__dontExport = true;
|
||||
|
||||
fup-repl = final.writeShellScriptBin "repl" ''
|
||||
case "$1" in
|
||||
"-h"|"--help"|"help")
|
||||
printf "%b\n\e[4mUsage\e[0m: \
|
||||
${example "repl" "Loads system flake if available."} \
|
||||
${example "repl /path/to/flake.nix" "Loads specified flake."}\n"
|
||||
;;
|
||||
*)
|
||||
if [ -z "$1" ]; then
|
||||
nix repl ${./repl.nix}
|
||||
else
|
||||
nix repl --arg flakePath $(${final.coreutils}/bin/readlink -f $1 | ${final.gnused}/bin/sed 's|/flake.nix||') ${./repl.nix}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
'';
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
inputs.utils.url = path:../../;
|
||||
inputs.nixpkgs.url = github:NixOS/nixpkgs/3c4a65f323dd;
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, utils }:
|
||||
utils.lib.mkFlake {
|
||||
@ -24,7 +25,6 @@
|
||||
hosts.PatchedHost.modules = [
|
||||
({ lib, ... }: {
|
||||
patchedModule.test = lib.patchedFunction "using patched module via patched function";
|
||||
nixpkgs.config.packageOverrides = pkgs: { };
|
||||
|
||||
# To keep Nix from complaining
|
||||
boot.loader.grub.devices = [ "nodev" ];
|
||||
@ -54,7 +54,7 @@
|
||||
{
|
||||
|
||||
# Patched package gets passed to `packageBuilder`
|
||||
patchedPackageGetsPassedToBuilders = isEqual self.packages.x86_64-linux.flake-utils-plus-test.pname "hello";
|
||||
patchedPackageGetsPassedToBuilders = isEqual self.packages.x86_64-linux.flake-utils-plus-test.pname "coreutils";
|
||||
|
||||
# Modules (and lib) from patched nixpkgs are used
|
||||
patchedModuleAndFunctionWorks = isEqual hostConfig.patchedModule.test "using patched module via patched function";
|
||||
@ -65,9 +65,6 @@
|
||||
# `channels.nixpkgs.config.*` is also used
|
||||
channelSpecificConfigWorks = hasKey hostConfig.nixpkgs.pkgs.config "allowUnfree";
|
||||
|
||||
# `options.nixpkgs.config.*` is also used
|
||||
modulesNixpkgsConfigWorks = hasKey hostConfig.nixpkgs.pkgs.config "packageOverrides";
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,23 +1,23 @@
|
||||
diff --git a/lib/default.nix b/lib/default.nix
|
||||
index 5a85c542117..0ed00136d1d 100644
|
||||
index 169f013191b8..05e91f1cd27b 100644
|
||||
--- a/lib/default.nix
|
||||
+++ b/lib/default.nix
|
||||
@@ -146,5 +146,7 @@ let
|
||||
nixType imap;
|
||||
inherit (self.versions)
|
||||
splitVersion;
|
||||
+
|
||||
@@ -10,6 +10,7 @@ let
|
||||
lib = makeExtensible (self: let
|
||||
callLibs = file: import file { lib = self; };
|
||||
in {
|
||||
+ patchedFunction = x: x;
|
||||
});
|
||||
in lib
|
||||
|
||||
# often used, or depending on very little
|
||||
trivial = callLibs ./trivial.nix;
|
||||
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
|
||||
index c951db5822a..53226de942e 100644
|
||||
index ec6f410a48f6..3c6669988d2f 100644
|
||||
--- a/nixos/modules/module-list.nix
|
||||
+++ b/nixos/modules/module-list.nix
|
||||
@@ -1191,4 +1191,10 @@
|
||||
./virtualisation/vmware-guest.nix
|
||||
./virtualisation/xen-dom0.nix
|
||||
@@ -1505,4 +1505,10 @@
|
||||
./virtualisation/xe-guest-utilities.nix
|
||||
./virtualisation/xen-dom0.nix
|
||||
{ documentation.nixos.extraModules = [ ./virtualisation/qemu-vm.nix ]; }
|
||||
+ ({ lib, config, ... }: {
|
||||
+ options.patchedModule.test = lib.mkOption {
|
||||
+ default = null;
|
||||
@ -26,15 +26,13 @@ index c951db5822a..53226de942e 100644
|
||||
+ })
|
||||
]
|
||||
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
|
||||
index c904707b7cf..9f0cab1875d 100644
|
||||
index 0c2a44d531df..299ff71619b6 100644
|
||||
--- a/pkgs/top-level/all-packages.nix
|
||||
+++ b/pkgs/top-level/all-packages.nix
|
||||
@@ -12,6 +12,8 @@ with pkgs;
|
||||
@@ -42286,4 +42286,6 @@ with pkgs;
|
||||
ssl-proxy = callPackage ../tools/networking/ssl-proxy { };
|
||||
|
||||
{
|
||||
|
||||
+ flake-utils-plus-test = callPackage ../applications/misc/hello { };
|
||||
code-maat = callPackage ../development/tools/code-maat {};
|
||||
+
|
||||
# A stdenv capable of building 32-bit binaries. On x86_64-linux,
|
||||
# it uses GCC compiled with multilib support; on i686-linux, it's
|
||||
# just the plain stdenv.
|
||||
+ flake-utils-plus-test = callPackage ../tools/misc/coreutils { };
|
||||
}
|
||||
|
@ -43,14 +43,6 @@
|
||||
|
||||
hosts.ExistingPkgsFlow = { };
|
||||
|
||||
hosts.ReimportFlow.modules = [
|
||||
{
|
||||
# Custom configuration from modules causes reimport of nixpkgs
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
||||
######################
|
||||
### Test execution ###
|
||||
@ -61,7 +53,6 @@
|
||||
let
|
||||
inherit (utils.lib.check-utils channels.nixpkgs) hasKey;
|
||||
existingPkgsFlow = self.nixosConfigurations.ExistingPkgsFlow.pkgs;
|
||||
reimportFlow = self.nixosConfigurations.ReimportFlow.pkgs;
|
||||
in
|
||||
{
|
||||
|
||||
@ -74,16 +65,6 @@
|
||||
|
||||
contains_srcs_1 = hasKey existingPkgsFlow "srcs";
|
||||
|
||||
|
||||
# ReimportFlow
|
||||
sharedOverlays_Applied_2 = hasKey reimportFlow "fromSharedOverlays";
|
||||
|
||||
channelSpecific_Applied_2 = hasKey reimportFlow "fromChannelSpecific";
|
||||
|
||||
hostConfig_Applied_2 = hasKey reimportFlow "fromHostConfig";
|
||||
|
||||
contains_srcs_2 = hasKey reimportFlow "srcs";
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user