finish moving cascade-local out of cascade

This commit is contained in:
James Andariese 2022-09-30 21:54:00 -05:00
parent 8694d5bff1
commit 3c9c9c94d9
7 changed files with 103 additions and 108 deletions

63
common/cascade-local.nix Normal file
View File

@ -0,0 +1,63 @@
with builtins;
with import (toString ../functions);
{pkgs, config, lib, ...}: {
options = with lib; with types; {
cascade.local.git-url = mkOption {
default = null;
type = nullOr str;
description = ''
git URL where cascade sources can be found
'';
};
};
config = with lib; {
#system.activationScripts.cascade-local-source = mkMerge [
# (mkIf (config.cascade.local.git-url != null) ''
# if [ ! -f /usr/src/cascade-local/.created-by-nixos ];then
# mkdir -m 0755 -p /usr/src
# # if it's just a symlink, delete it.
# if [ -e /usr/src/cascade-local.before-nixos ] ;then
# 1>&2 echo "there is already a backup at /usr/src/cascade-local.before-nixos"
# exit 1
# fi
# if [ -h /usr/src/cascade-local.before-nixos ];then
# rm -v /usr/src/cascade-local.before-nixos
# fi
# [ -e /usr/src/cascade-local ] && mv /usr/src/cascade-local /usr/src/cascade-local.before-nixos
# ${pkgs.git}/bin/git clone ${config.cascade.source.git-url} /usr/src/cascade-local
# touch /usr/src/cascade-local/.created-by-nixosa
# fi
# '')
# (mkIf (config.cascade.local.git-url == null) ''
# # if it's a symlink, just delete it.
# if [ -h /usr/src/cascade-local ];then
# rm -v /usr/src/cascade-local
# fi
# # only cleanup if we actually created /usr/src/cascade-local
# if [ -f /usr/src/cascade-local/.created-by-nixos ];then
# rm -rf /usr/src/cascade-local && \
# [ -e /usr/src/cascade-local.before-nixos ] && mv /usr/src/cascade-local.before-nixos /usr/src/cascade-local
# fi
#
# mkdir -m 0755 -p /usr/src
# if [ -h /usr/src/cascade-local.before-nixos ];then
# rm -v /usr/src/cascade-local.before-nixos
# fi
# if [ -e /usr/src/cascade-local ];then
# mv /usr/src/cascade-local /usr/src/cascade-local.before-nixos
# fi
# ln -sfn ${<cascade-local>} /usr/src/cascade-local
# '')
#];
# no matter what, we always set cascade-local in NIX_PATH to /usr/src/cascade-local
nix.nixPath = [ "cascade-local=/usr/src/cascade-local" ];
};
}

View File

@ -4,27 +4,25 @@ with import (toString ../functions);
{pkgs, config, lib, ...}: {
options = with lib; with types; {
cascade.nixpkgs-source = mkOption {
default = null;
type = nullOr str;
description = ''
where to point nixpkgs in NIX_PATH for the system.
if null, nixpkgs will not be set by this module
'';
};
cascade.source.enable = mkOption {
default = true;
type = bool;
description = ''
Include cascade source code configured for nixos-rebuild.
'';
};
cascade.source.git-url = mkOption {
default = "https://gitlab.com/jamesandariese/cascade";
#cascade.source.enable = mkOption {
# default = true;
# type = bool;
# description = ''
# Include cascade source code configured for nixos-rebuild.
# '';
#};
#cascade.source.git-url = mkOption {
# default = "https://gitlab.com/jamesandariese/cascade";
# type = str;
# description = ''
# git URL where cascade sources can be found
# '';
#};
cascade.source.path = mkOption {
default = "${<cascade>}";
type = str;
description = ''
git URL where cascade sources can be found
where to get cascade source from
'';
};
cascade.source.set-nix-path = mkOption {
@ -39,28 +37,30 @@ options = with lib; with types; {
};
config = with lib; {
system.activationScripts.cascade-source = mkMerge [
(mkIf config.cascade.source.enable ''
if [ ! -f /usr/src/cascade/.created-by-nixos ];then
mkdir -m 0755 -p /usr/src /etc/nixos
# if it's just a symlink, delete it.
[ -e /usr/src/cascade ] && mv /usr/src/cascade /usr/src/cascade.before-nixos
${pkgs.git}/bin/git clone ${config.cascade.source.git-url} /usr/src/cascade
touch /usr/src/cascade/.created-by-nixos
fi
'')
(mkIf (!config.cascade.source.enable) ''
# only cleanup if we actually created /usr/src/cascade
if [ -f /usr/src/cascade/.created-by-nixos ];then
rm -rf /usr/src/cascade && \
[ -e /usr/src/cascade.before-nixos ] && mv /usr/src/cascade.before-nixos /usr/src/cascade
fi
'')
];
#system.activationScripts.cascade-source = mkMerge [
# (mkIf config.cascade.source.enable ''
# if [ ! -f /usr/src/cascade/.created-by-nixos ];then
# mkdir -m 0755 -p /usr/src /etc/nixos
# # if it's just a symlink, delete it.
# [ -e /usr/src/cascade ] && mv /usr/src/cascade /usr/src/cascade.before-nixos
# ${pkgs.git}/bin/git clone ${config.cascade.source.git-url} /usr/src/cascade
# touch /usr/src/cascade/.created-by-nixos
# fi
# '')
# (mkIf (!config.cascade.source.enable) ''
# # only cleanup if we actually created /usr/src/cascade
# if [ -f /usr/src/cascade/.created-by-nixos ];then
# rm -rf /usr/src/cascade && \
# [ -e /usr/src/cascade.before-nixos ] && mv /usr/src/cascade.before-nixos /usr/src/cascade
# fi
# '')
#];
nix.nixPath = mkMerge [
(mkIf (config.cascade.nixpkgs-source != null) [ "nixpkgs=${config.cascade.nixpkgs-source}" ])
(mkIf (config.cascade.source.set-nix-path && config.cascade.source.enable) [ "cascade=/usr/src/cascade" ])
(mkIf (!(config.cascade.source.set-nix-path && config.cascade.source.enable)) [ "cascade=https://gitlab.com/jamesandariese/cascade/-/archive/main/cascade-main.tar.gz" ])
[ "nixpkgs=${import <cascade-local/nixpkgs-path.nix>}" ]
[ "cascade=${config.cascade.source.path}" ]
#(mkIf (config.cascade.source.set-nix-path && config.cascade.source.enable) [ "cascade=/usr/src/cascade" ])
#(mkIf (!(config.cascade.source.set-nix-path && config.cascade.source.enable)) [ "cascade=https://gitlab.com/jamesandariese/cascade/-/archive/main/cascade-main.tar.gz" ])
];
};

View File

@ -1,23 +0,0 @@
with builtins;
{}:
let
myisoconfig = import ./hosts/_basic.nix;
copyChannel = true;
system = "x86_64-linux";
evalNixos = configuration: import <nixpkgs/nixos> {
inherit system configuration;
};
resultOfEval = (evalNixos myisoconfig);
lib = resultOfEval.pkgs.lib;
pkgs = resultOfEval.pkgs;
config = resultOfEval.config;
in
import <nixpkgs/nixos/lib/make-disk-image.nix> {
inherit lib copyChannel pkgs config;
diskSize = "20480";
format = "raw";
installBootLoader = true;
partitionTableType = "hybrid";
}

3
hosts/.gitignore vendored
View File

@ -1,3 +0,0 @@
*.nix
!_*.nix
!default.nix

View File

@ -1,14 +0,0 @@
{
imports = [
(toString ../profiles/qemu-vm-install-media)
];
config = {
#deployment.targetHost = "";
#deployment.targetUser = "";
#deployment.targetPort = "";
networking.hostName = "nixos";
#networking.interfaces.br0.ipv4.addresses = [ ];
#networking.interfaces.br0.ipv4.routes = [ {address = "0.0.0.0"; prefixLength = 0; via = "172.16.1.1"; } ];
#networking.interfaces.br0.useDHCP = false;
};
}

View File

@ -1,13 +0,0 @@
let _ = builtins.trace "${toString ./.}/default.nix"; in
with builtins;
with import (toString ../functions);
let hosts = import-folder {path = "${toString ./.}"; filenameMatch = ".*[.]nix"; filenameBadMatch = ".*_.*";};
in
{...}:
mapAttrs (hostname: hostdef:
{...}: hostdef
) hosts

View File

@ -1,15 +0,0 @@
let pkgs = import <nixpkgs> {};
in
if pkgs == null then
builtins.fetchGit {
url = "https://github.com/nixos/nixpkgs";
ref = "master";
rev = "da4c6be0187a694bdeb3efc28b29ee0e4c30702f";
shallow = true;
}
else pkgs.fetchgit {
url = "https://github.com/nixos/nixpkgs";
rev = "da4c6be0187a694bdeb3efc28b29ee0e4c30702f";
sha256 = "sha256-1rcG6x0vKnnzGhABPg/QvL75DzhJxM810wZKAukoF1M=";
}