2023-01-14 23:20:38 +00:00
|
|
|
# FLAKE FEEDBACK:
|
2023-01-15 04:10:10 +00:00
|
|
|
# - if flake inputs are meant to be human-readable, a human should be able to easily track them down given the URL.
|
|
|
|
# - this is not the case with registry URLs, like `nixpkgs/nixos-22.11`.
|
|
|
|
# - this is marginally the case with schemes like `github:nixos/nixpkgs`.
|
|
|
|
# - given the *existing* `git+https://` scheme, i propose expressing github URLs similarly:
|
|
|
|
# - `github+https://github.com/nixos/nixpkgs/tree/nixos-22.11`
|
2023-09-24 08:16:19 +00:00
|
|
|
# - this would allow for the same optimizations as today's `github:nixos/nixpkgs`, but without obscuring the source.
|
|
|
|
# a code reader could view the source being referenced simply by clicking the https:// portion of that URI.
|
2023-01-15 04:10:10 +00:00
|
|
|
# - need some way to apply local patches to inputs.
|
2023-01-14 23:20:38 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# DEVELOPMENT DOCS:
|
2023-01-15 04:10:10 +00:00
|
|
|
# - Flake docs: <https://nixos.wiki/wiki/Flakes>
|
|
|
|
# - Flake RFC: <https://github.com/tweag/rfcs/blob/flakes/rfcs/0049-flakes.md>
|
|
|
|
# - Discussion: <https://github.com/NixOS/rfcs/pull/49>
|
2022-08-25 02:46:10 +00:00
|
|
|
# - <https://serokell.io/blog/practical-nix-flakes>
|
2023-03-29 12:04:43 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# COMMON OPERATIONS:
|
|
|
|
# - update a specific flake input:
|
|
|
|
# - `nix flake lock --update-input nixpkgs`
|
2022-05-21 00:07:49 +00:00
|
|
|
|
|
|
|
{
|
2023-01-15 04:10:10 +00:00
|
|
|
# XXX: use the `github:` scheme instead of the more readable git+https: because it's *way* more efficient
|
|
|
|
# preferably, i would rewrite the human-readable https URLs to nix-specific github: URLs with a helper,
|
|
|
|
# but `inputs` is required to be a strict attrset: not an expression.
|
2022-05-21 00:07:49 +00:00
|
|
|
inputs = {
|
2023-04-15 23:06:37 +00:00
|
|
|
# branch workflow:
|
|
|
|
# - daily:
|
|
|
|
# - nixos-unstable cut from master after enough packages have been built in caches.
|
|
|
|
# - every 6 hours:
|
|
|
|
# - master auto-merged into staging.
|
|
|
|
# - staging-next auto-merged into staging.
|
|
|
|
# - manually, approximately once per month:
|
|
|
|
# - staging-next is cut from staging.
|
|
|
|
# - staging-next merged into master.
|
|
|
|
#
|
|
|
|
# which branch to source from?
|
|
|
|
# - for everyday development, prefer `nixos-unstable` branch, as it provides good caching.
|
|
|
|
# - if need to test bleeding updates (e.g. if submitting code into staging):
|
|
|
|
# - use `staging-next` if it's been cut (i.e. if there's an active staging-next -> master PR)
|
|
|
|
# - use `staging` if no staging-next branch has been cut.
|
|
|
|
#
|
2023-01-15 04:10:10 +00:00
|
|
|
# <https://github.com/nixos/nixpkgs/tree/nixos-unstable>
|
2023-05-10 23:32:31 +00:00
|
|
|
nixpkgs-unpatched.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
|
|
# nixpkgs-unpatched.url = "github:nixos/nixpkgs?ref=staging-next";
|
2023-04-15 23:06:37 +00:00
|
|
|
# nixpkgs-unpatched.url = "github:nixos/nixpkgs?ref=staging";
|
2023-03-01 13:01:41 +00:00
|
|
|
|
2022-05-23 02:45:54 +00:00
|
|
|
mobile-nixos = {
|
2023-01-15 04:10:10 +00:00
|
|
|
# <https://github.com/nixos/mobile-nixos>
|
2023-09-25 13:35:50 +00:00
|
|
|
# only used for building disk images, not relevant after deployment
|
2023-01-15 04:10:10 +00:00
|
|
|
url = "github:nixos/mobile-nixos";
|
2022-05-24 05:47:32 +00:00
|
|
|
flake = false;
|
2022-05-23 02:45:54 +00:00
|
|
|
};
|
2022-10-11 00:19:57 +00:00
|
|
|
sops-nix = {
|
2023-01-15 04:10:10 +00:00
|
|
|
# <https://github.com/Mic92/sops-nix>
|
2023-09-25 13:35:50 +00:00
|
|
|
# used to distribute secrets to my hosts
|
2023-01-15 04:10:10 +00:00
|
|
|
url = "github:Mic92/sops-nix";
|
2023-03-01 13:01:41 +00:00
|
|
|
# inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs-unpatched";
|
2022-10-11 00:19:57 +00:00
|
|
|
};
|
2023-01-11 08:45:41 +00:00
|
|
|
uninsane-dot-org = {
|
2023-09-25 13:35:50 +00:00
|
|
|
# provides the package to deploy <https://uninsane.org>, used only when building the servo host
|
2022-10-11 10:22:40 +00:00
|
|
|
url = "git+https://git.uninsane.org/colin/uninsane";
|
2023-03-01 13:01:41 +00:00
|
|
|
# inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs-unpatched";
|
2022-10-11 10:22:40 +00:00
|
|
|
};
|
2022-05-21 00:07:49 +00:00
|
|
|
};
|
2022-05-21 07:30:29 +00:00
|
|
|
|
2022-10-27 10:20:29 +00:00
|
|
|
outputs = {
|
|
|
|
self,
|
2023-01-10 17:00:43 +00:00
|
|
|
nixpkgs-unpatched,
|
2022-10-27 10:20:29 +00:00
|
|
|
mobile-nixos,
|
|
|
|
sops-nix,
|
2023-01-31 04:09:49 +00:00
|
|
|
uninsane-dot-org,
|
|
|
|
...
|
|
|
|
}@inputs:
|
2022-06-23 22:57:20 +00:00
|
|
|
let
|
2023-03-11 10:01:25 +00:00
|
|
|
inherit (builtins) attrNames elem listToAttrs map mapAttrs;
|
2023-09-24 15:30:12 +00:00
|
|
|
# redefine some nixpkgs `lib` functions to avoid the infinite recursion
|
|
|
|
# of if we tried to use patched `nixpkgs.lib` as part of the patching process.
|
2023-03-01 23:33:32 +00:00
|
|
|
mapAttrs' = f: set:
|
|
|
|
listToAttrs (map (attr: f attr set.${attr}) (attrNames set));
|
2023-09-24 15:30:12 +00:00
|
|
|
optionalAttrs = cond: attrs: if cond then attrs else {};
|
2023-03-01 23:33:32 +00:00
|
|
|
# mapAttrs but without the `name` argument
|
|
|
|
mapAttrValues = f: mapAttrs (_: f);
|
2023-09-24 15:30:12 +00:00
|
|
|
|
2023-03-01 13:01:41 +00:00
|
|
|
# rather than apply our nixpkgs patches as a flake input, do that here instead.
|
|
|
|
# this (temporarily?) resolves the bad UX wherein a subflake residing in the same git
|
|
|
|
# repo as the main flake causes the main flake to have an unstable hash.
|
|
|
|
nixpkgs = (import ./nixpatches/flake.nix).outputs {
|
|
|
|
self = nixpkgs;
|
|
|
|
nixpkgs = nixpkgs-unpatched;
|
2023-09-24 15:30:12 +00:00
|
|
|
} // {
|
|
|
|
# provide values that nixpkgs ordinarily sources from the flake.lock file,
|
|
|
|
# inaccessible to it here because of the import-from-derivation.
|
|
|
|
# rev and shortRev seem to not always exist (e.g. if the working tree is dirty),
|
|
|
|
# so those are made conditional.
|
|
|
|
#
|
|
|
|
# these values impact the name of a produced nixos system. having date/rev in the
|
|
|
|
# `readlink /run/current-system` store path helps debuggability.
|
|
|
|
inherit (self) lastModifiedDate lastModified;
|
|
|
|
} // optionalAttrs (self ? rev) {
|
|
|
|
inherit (self) rev;
|
|
|
|
} // optionalAttrs (self ? shortRev) {
|
|
|
|
inherit (self) shortRev;
|
2023-03-01 13:01:41 +00:00
|
|
|
};
|
|
|
|
|
2023-05-15 09:59:18 +00:00
|
|
|
nixpkgsCompiledBy = system: nixpkgs.legacyPackages."${system}";
|
2022-12-14 12:27:24 +00:00
|
|
|
|
2023-05-15 09:59:18 +00:00
|
|
|
evalHost = { name, local, target }: nixpkgs.lib.nixosSystem {
|
|
|
|
system = target;
|
|
|
|
modules = [
|
2023-08-05 09:32:50 +00:00
|
|
|
{
|
|
|
|
nixpkgs = (if (local != null) then {
|
|
|
|
buildPlatform = local;
|
|
|
|
} else {}) // {
|
|
|
|
# TODO: does the earlier `system` arg to nixosSystem make its way here?
|
|
|
|
hostPlatform.system = target;
|
|
|
|
};
|
|
|
|
# nixpkgs.buildPlatform = local; # set by instantiate.nix instead
|
|
|
|
# nixpkgs.config.replaceStdenv = { pkgs }: pkgs.ccacheStdenv;
|
|
|
|
}
|
|
|
|
(import ./hosts/instantiate.nix { hostName = name; })
|
2023-05-15 09:59:18 +00:00
|
|
|
self.nixosModules.default
|
|
|
|
self.nixosModules.passthru
|
|
|
|
{
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
self.overlays.passthru
|
2023-05-24 03:57:35 +00:00
|
|
|
self.overlays.sane-all
|
2023-01-11 05:58:07 +00:00
|
|
|
];
|
2023-05-15 09:59:18 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2023-01-11 09:24:24 +00:00
|
|
|
in {
|
2023-03-01 23:33:32 +00:00
|
|
|
nixosConfigurations =
|
|
|
|
let
|
|
|
|
hosts = {
|
|
|
|
servo = { name = "servo"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
|
|
|
desko = { name = "desko"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
|
|
|
lappy = { name = "lappy"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
|
|
|
moby = { name = "moby"; local = "x86_64-linux"; target = "aarch64-linux"; };
|
|
|
|
rescue = { name = "rescue"; local = "x86_64-linux"; target = "x86_64-linux"; };
|
|
|
|
};
|
|
|
|
# cross-compiled builds: instead of emulating the host, build using a cross-compiler.
|
|
|
|
# - these are faster to *build* than the emulated variants (useful when tweaking packages),
|
|
|
|
# - but fewer of their packages can be found in upstream caches.
|
|
|
|
cross = mapAttrValues evalHost hosts;
|
|
|
|
emulated = mapAttrValues
|
|
|
|
({name, local, target}: evalHost {
|
|
|
|
inherit name target;
|
|
|
|
local = null;
|
|
|
|
})
|
|
|
|
hosts;
|
|
|
|
prefixAttrs = prefix: attrs: mapAttrs'
|
|
|
|
(name: value: {
|
|
|
|
name = prefix + name;
|
|
|
|
inherit value;
|
|
|
|
})
|
|
|
|
attrs;
|
|
|
|
in
|
|
|
|
(prefixAttrs "cross-" cross) //
|
|
|
|
(prefixAttrs "emulated-" emulated) // {
|
|
|
|
# prefer native builds for these machines:
|
|
|
|
inherit (emulated) servo desko lappy rescue;
|
|
|
|
# prefer cross-compiled builds for these machines:
|
|
|
|
inherit (cross) moby;
|
|
|
|
};
|
2023-01-11 08:56:06 +00:00
|
|
|
|
|
|
|
# unofficial output
|
2023-01-11 09:24:24 +00:00
|
|
|
# this produces a EFI-bootable .img file (GPT with a /boot partition and a system (/ or /nix) partition).
|
|
|
|
# after building this:
|
|
|
|
# - flash it to a bootable medium (SD card, flash drive, HDD)
|
|
|
|
# - resize the root partition (use cfdisk)
|
|
|
|
# - mount the part
|
|
|
|
# - chown root:nixbld <part>/nix/store
|
|
|
|
# - chown root:root -R <part>/nix/store/*
|
|
|
|
# - chown root:root -R <part>/persist # if using impermanence
|
|
|
|
# - populate any important things (persist/, home/colin/.ssh, etc)
|
|
|
|
# - boot
|
|
|
|
# - if fs wasn't resized automatically, then `sudo btrfs filesystem resize max /`
|
|
|
|
# - checkout this flake into /etc/nixos AND UPDATE THE FS UUIDS.
|
|
|
|
# - `nixos-rebuild --flake './#<host>' switch`
|
2023-03-01 23:33:32 +00:00
|
|
|
imgs = mapAttrValues (host: host.config.system.build.img) self.nixosConfigurations;
|
2023-01-11 05:58:07 +00:00
|
|
|
|
2023-03-01 23:33:32 +00:00
|
|
|
# unofficial output
|
|
|
|
host-pkgs = mapAttrValues (host: host.config.system.build.pkgs) self.nixosConfigurations;
|
2023-05-24 23:32:21 +00:00
|
|
|
host-programs = mapAttrValues (host: mapAttrValues (p: p.package) host.config.sane.programs) self.nixosConfigurations;
|
2023-02-05 19:34:32 +00:00
|
|
|
|
2023-03-11 10:01:25 +00:00
|
|
|
overlays = {
|
|
|
|
# N.B.: `nix flake check` requires every overlay to take `final: prev:` at defn site,
|
|
|
|
# hence the weird redundancy.
|
|
|
|
default = final: prev: self.overlays.pkgs final prev;
|
2023-05-24 03:57:35 +00:00
|
|
|
sane-all = final: prev: import ./overlays/all.nix final prev;
|
2023-04-04 23:30:27 +00:00
|
|
|
disable-flakey-tests = final: prev: import ./overlays/disable-flakey-tests.nix final prev;
|
2023-03-11 10:01:25 +00:00
|
|
|
pkgs = final: prev: import ./overlays/pkgs.nix final prev;
|
|
|
|
pins = final: prev: import ./overlays/pins.nix final prev;
|
2023-08-02 06:38:46 +00:00
|
|
|
preferences = final: prev: import ./overlays/preferences.nix final prev;
|
2023-03-11 10:01:25 +00:00
|
|
|
optimizations = final: prev: import ./overlays/optimizations.nix final prev;
|
|
|
|
passthru = final: prev:
|
2023-01-11 08:45:41 +00:00
|
|
|
let
|
|
|
|
mobile = (import "${mobile-nixos}/overlay/overlay.nix");
|
|
|
|
uninsane = uninsane-dot-org.overlay;
|
|
|
|
in
|
2023-06-29 22:47:51 +00:00
|
|
|
(mobile final prev)
|
|
|
|
// (uninsane final prev)
|
|
|
|
;
|
2023-01-11 08:45:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nixosModules = rec {
|
|
|
|
default = sane;
|
|
|
|
sane = import ./modules;
|
|
|
|
passthru = { ... }: {
|
|
|
|
imports = [
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
];
|
|
|
|
};
|
2023-01-11 07:22:21 +00:00
|
|
|
};
|
|
|
|
|
2023-01-11 09:21:09 +00:00
|
|
|
# this includes both our native packages and all the nixpkgs packages.
|
|
|
|
legacyPackages =
|
2023-01-11 05:58:07 +00:00
|
|
|
let
|
2023-01-11 09:21:09 +00:00
|
|
|
allPkgsFor = sys: (nixpkgsCompiledBy sys).appendOverlays [
|
|
|
|
self.overlays.passthru self.overlays.pkgs
|
|
|
|
];
|
2023-01-11 05:58:07 +00:00
|
|
|
in {
|
|
|
|
x86_64-linux = allPkgsFor "x86_64-linux";
|
|
|
|
aarch64-linux = allPkgsFor "aarch64-linux";
|
|
|
|
};
|
|
|
|
|
2023-03-11 10:01:25 +00:00
|
|
|
# extract only our own packages from the full set.
|
|
|
|
# because of `nix flake check`, we flatten the package set and only surface x86_64-linux packages.
|
|
|
|
packages = mapAttrs
|
|
|
|
(system: allPkgs:
|
|
|
|
allPkgs.lib.filterAttrs (name: pkg:
|
|
|
|
# keep only packages which will pass `nix flake check`, i.e. keep only:
|
|
|
|
# - derivations (not package sets)
|
|
|
|
# - packages that build for the given platform
|
|
|
|
(! elem name [ "feeds" "pythonPackagesExtensions" ])
|
|
|
|
&& (allPkgs.lib.meta.availableOn allPkgs.stdenv.hostPlatform pkg)
|
|
|
|
)
|
2023-05-03 05:59:48 +00:00
|
|
|
(
|
|
|
|
# expose sane packages and chosen inputs (uninsane.org)
|
|
|
|
(import ./pkgs { pkgs = allPkgs; }) // {
|
|
|
|
inherit (allPkgs) uninsane-dot-org;
|
|
|
|
}
|
|
|
|
)
|
2023-03-11 10:01:25 +00:00
|
|
|
)
|
|
|
|
# self.legacyPackages;
|
|
|
|
{ inherit (self.legacyPackages) x86_64-linux; }
|
|
|
|
;
|
2023-01-11 09:21:09 +00:00
|
|
|
|
2023-01-11 10:41:39 +00:00
|
|
|
apps."x86_64-linux" =
|
|
|
|
let
|
|
|
|
pkgs = self.legacyPackages."x86_64-linux";
|
2023-09-24 10:27:32 +00:00
|
|
|
sanePkgs = import ./pkgs { inherit pkgs; };
|
2023-07-30 11:23:02 +00:00
|
|
|
deployScript = host: addr: action: pkgs.writeShellScript "deploy-${host}" ''
|
2023-07-18 09:10:25 +00:00
|
|
|
nix build '.#nixosConfigurations.${host}.config.system.build.toplevel' --out-link ./result-${host} $@
|
|
|
|
sudo nix sign-paths -r -k /run/secrets/nix_serve_privkey $(readlink ./result-${host})
|
|
|
|
|
|
|
|
# XXX: this triggers another config eval & (potentially) build.
|
|
|
|
# if the config changed between these invocations, the above signatures might not apply to the deployed config.
|
|
|
|
# let the user handle that edge case by re-running this whole command
|
2023-07-30 11:23:02 +00:00
|
|
|
nixos-rebuild --flake '.#${host}' ${action} --target-host colin@${addr} --use-remote-sudo $@
|
2023-03-02 07:49:29 +00:00
|
|
|
'';
|
2023-09-24 12:11:28 +00:00
|
|
|
|
|
|
|
# pkg updating.
|
|
|
|
# a cleaner alternative lives here: <https://discourse.nixos.org/t/how-can-i-run-the-updatescript-of-personal-packages/25274/2>
|
2023-09-24 08:16:19 +00:00
|
|
|
mkUpdater = attrPath: {
|
|
|
|
type = "app";
|
|
|
|
program = let
|
2023-09-24 10:27:32 +00:00
|
|
|
pkg = pkgs.lib.getAttrFromPath attrPath sanePkgs;
|
2023-09-24 08:16:19 +00:00
|
|
|
strAttrPath = pkgs.lib.concatStringsSep "." attrPath;
|
2023-09-27 19:09:29 +00:00
|
|
|
commandArgv = pkg.updateScript.command or pkg.updateScript;
|
|
|
|
command = pkgs.lib.escapeShellArgs commandArgv;
|
2023-09-24 12:11:28 +00:00
|
|
|
in builtins.toString (pkgs.writeShellScript "update-${strAttrPath}" ''
|
2023-09-24 08:16:19 +00:00
|
|
|
export UPDATE_NIX_NAME=${pkg.name}
|
|
|
|
export UPDATE_NIX_PNAME=${pkg.pname}
|
|
|
|
export UPDATE_NIX_OLD_VERSION=${pkg.version}
|
|
|
|
export UPDATE_NIX_ATTR_PATH=${strAttrPath}
|
2023-09-24 12:11:28 +00:00
|
|
|
${command}
|
2023-09-24 08:16:19 +00:00
|
|
|
'');
|
|
|
|
};
|
2023-09-24 12:35:39 +00:00
|
|
|
mkUpdatersNoAliases = opts: basePath: pkgs.lib.concatMapAttrs
|
2023-09-24 10:27:32 +00:00
|
|
|
(name: pkg:
|
|
|
|
if pkg.recurseForDerivations or false then {
|
2023-09-24 12:35:39 +00:00
|
|
|
"${name}" = mkUpdaters opts (basePath ++ [ name ]);
|
2023-09-24 10:27:32 +00:00
|
|
|
} else if pkg.updateScript or null != null then {
|
|
|
|
"${name}" = mkUpdater (basePath ++ [ name ]);
|
|
|
|
} else {}
|
|
|
|
)
|
|
|
|
(pkgs.lib.getAttrFromPath basePath sanePkgs);
|
2023-09-24 12:35:39 +00:00
|
|
|
mkUpdaters = { ignore ? [] }@opts: basePath:
|
2023-09-24 10:50:02 +00:00
|
|
|
let
|
2023-09-24 12:35:39 +00:00
|
|
|
updaters = mkUpdatersNoAliases opts basePath;
|
2023-09-24 10:50:02 +00:00
|
|
|
invokeUpdater = name: pkg:
|
|
|
|
let
|
2023-09-24 12:35:39 +00:00
|
|
|
fullPath = basePath ++ [ name ];
|
|
|
|
doUpdateByDefault = !builtins.elem fullPath ignore;
|
|
|
|
|
2023-09-24 12:11:28 +00:00
|
|
|
# in case `name` has a `.` in it, we have to quote it
|
2023-09-24 12:35:39 +00:00
|
|
|
escapedPath = builtins.map (p: ''"${p}"'') fullPath;
|
2023-09-24 12:11:28 +00:00
|
|
|
updatePath = builtins.concatStringsSep "." ([ "update" "pkgs" ] ++ escapedPath);
|
2023-09-24 12:35:39 +00:00
|
|
|
in pkgs.lib.optionalString doUpdateByDefault (
|
|
|
|
pkgs.lib.escapeShellArgs [
|
|
|
|
"nix" "run" ".#${updatePath}"
|
|
|
|
]
|
2023-09-24 10:50:02 +00:00
|
|
|
);
|
2023-09-24 12:35:39 +00:00
|
|
|
in {
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (pkgs.writeShellScript
|
|
|
|
(builtins.concatStringsSep "-" (["update"] ++ basePath))
|
|
|
|
(builtins.concatStringsSep
|
|
|
|
"\n"
|
|
|
|
(pkgs.lib.mapAttrsToList invokeUpdater updaters)
|
|
|
|
)
|
|
|
|
);
|
2023-09-24 10:50:02 +00:00
|
|
|
} // updaters;
|
2023-01-11 10:41:39 +00:00
|
|
|
in {
|
2023-07-28 00:49:44 +00:00
|
|
|
help = {
|
|
|
|
type = "app";
|
|
|
|
program = let
|
|
|
|
helpMsg = builtins.toFile "nixos-config-help-message" ''
|
|
|
|
commands:
|
|
|
|
- `nix run '.#help'`
|
|
|
|
- show this message
|
2023-09-24 12:11:28 +00:00
|
|
|
- `nix run '.#update.pkgs'`
|
|
|
|
- updates every package
|
2023-09-24 12:35:39 +00:00
|
|
|
- `nix run '.#update.feeds'`
|
2023-07-28 00:49:44 +00:00
|
|
|
- updates metadata for all feeds
|
|
|
|
- `nix run '.#init-feed' <url>`
|
|
|
|
- `nix run '.#deploy-{lappy,moby,moby-test,servo}' [nixos-rebuild args ...]`
|
2023-09-25 13:09:02 +00:00
|
|
|
- `nix run '.#check'`
|
|
|
|
- make sure all systems build; NUR evaluates
|
2023-07-28 00:49:44 +00:00
|
|
|
'';
|
|
|
|
in builtins.toString (pkgs.writeShellScript "nixos-config-help" ''
|
|
|
|
cat ${helpMsg}
|
2023-09-27 18:38:06 +00:00
|
|
|
echo ""
|
|
|
|
echo "complete flake structure:"
|
|
|
|
nix flake show --option allow-import-from-derivation true
|
2023-07-28 00:49:44 +00:00
|
|
|
'');
|
|
|
|
};
|
2023-09-24 12:35:39 +00:00
|
|
|
update.pkgs = mkUpdaters { ignore = [ ["feeds"] ]; } [];
|
|
|
|
update.feeds = mkUpdaters {} [ "feeds" ];
|
2023-09-22 10:11:44 +00:00
|
|
|
|
2023-01-11 10:41:39 +00:00
|
|
|
init-feed = {
|
|
|
|
type = "app";
|
2023-09-24 12:11:28 +00:00
|
|
|
program = "${pkgs.feeds.init-feed}";
|
2023-01-11 10:41:39 +00:00
|
|
|
};
|
2023-03-02 07:49:29 +00:00
|
|
|
|
2023-07-18 09:10:25 +00:00
|
|
|
deploy-lappy = {
|
|
|
|
type = "app";
|
2023-07-30 11:23:02 +00:00
|
|
|
program = ''${deployScript "lappy" "lappy" "switch"}'';
|
2023-07-18 09:10:25 +00:00
|
|
|
};
|
2023-03-02 07:49:29 +00:00
|
|
|
deploy-moby-test = {
|
|
|
|
type = "app";
|
2023-07-30 11:23:02 +00:00
|
|
|
program = ''${deployScript "moby" "moby-hn" "test"}'';
|
2023-03-02 07:49:29 +00:00
|
|
|
};
|
2023-04-15 06:56:24 +00:00
|
|
|
deploy-moby = {
|
2023-03-02 07:49:29 +00:00
|
|
|
type = "app";
|
2023-07-30 11:23:02 +00:00
|
|
|
program = ''${deployScript "moby" "moby-hn" "switch"}'';
|
2023-07-06 22:40:25 +00:00
|
|
|
};
|
|
|
|
deploy-servo = {
|
|
|
|
type = "app";
|
2023-07-30 11:23:02 +00:00
|
|
|
program = ''${deployScript "servo" "servo" "switch"}'';
|
2023-03-02 07:49:29 +00:00
|
|
|
};
|
2023-06-26 01:26:13 +00:00
|
|
|
|
2023-08-14 08:20:06 +00:00
|
|
|
sync-moby = {
|
|
|
|
# copy music from the current device to moby
|
|
|
|
# TODO: should i actually sync from /mnt/servo-media/Music instead of the local drive?
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (pkgs.writeShellScript "sync-to-moby" ''
|
|
|
|
sudo mount /mnt/moby-home
|
|
|
|
${pkgs.sane-scripts.sync-music}/bin/sane-sync-music ~/Music /mnt/moby-home/Music
|
|
|
|
'');
|
|
|
|
};
|
|
|
|
|
2023-08-20 07:46:55 +00:00
|
|
|
sync-lappy = {
|
|
|
|
# copy music from servo to lappy
|
|
|
|
# can run this from any device that has ssh access to lappy
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (pkgs.writeShellScript "sync-to-lappy" ''
|
|
|
|
sudo mount /mnt/lappy-home
|
|
|
|
${pkgs.sane-scripts.sync-music}/bin/sane-sync-music /mnt/servo-media/Music /mnt/lappy-home/Music
|
|
|
|
'');
|
|
|
|
};
|
|
|
|
|
2023-09-25 13:09:02 +00:00
|
|
|
check = {
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (pkgs.writeShellScript "check-all" ''
|
|
|
|
nix run '.#check.nur'
|
|
|
|
RC0=$?
|
|
|
|
nix run '.#check.host-configs'
|
|
|
|
RC1=$?
|
|
|
|
echo "nur: $RC0"
|
|
|
|
echo "host-configs: $RC1"
|
|
|
|
exit $(($RC0 | $RC1))
|
|
|
|
'');
|
|
|
|
};
|
|
|
|
|
|
|
|
check.nur = {
|
2023-06-26 01:26:13 +00:00
|
|
|
# `nix run '.#check-nur'`
|
|
|
|
# validates that my repo can be included in the Nix User Repository
|
|
|
|
type = "app";
|
|
|
|
program = builtins.toString (pkgs.writeShellScript "check-nur" ''
|
|
|
|
cd ${./.}/integrations/nur
|
|
|
|
NIX_PATH= NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-env -f . -qa \* --meta --xml \
|
|
|
|
--allowed-uris https://static.rust-lang.org \
|
|
|
|
--option restrict-eval true \
|
|
|
|
--option allow-import-from-derivation true \
|
|
|
|
--drv-path --show-trace \
|
|
|
|
-I nixpkgs=$(nix-instantiate --find-file nixpkgs) \
|
2023-09-25 13:09:02 +00:00
|
|
|
-I ../../ \
|
|
|
|
| tee # tee to prevent interactive mode
|
2023-06-26 01:26:13 +00:00
|
|
|
'');
|
|
|
|
};
|
2023-09-02 01:25:20 +00:00
|
|
|
|
2023-09-25 13:09:02 +00:00
|
|
|
check.host-configs = {
|
2023-09-02 01:25:20 +00:00
|
|
|
type = "app";
|
2023-09-25 13:09:02 +00:00
|
|
|
program = let
|
|
|
|
checkHost = host: ''
|
2023-10-18 06:00:07 +00:00
|
|
|
nix build -v '.#nixosConfigurations.${host}.config.system.build.toplevel' --out-link ./result-${host} -j2 $@
|
2023-09-25 13:09:02 +00:00
|
|
|
RC_${host}=$?
|
|
|
|
'';
|
|
|
|
in builtins.toString (pkgs.writeShellScript
|
2023-09-02 01:25:20 +00:00
|
|
|
"check-host-configs"
|
2023-09-25 13:09:02 +00:00
|
|
|
''
|
|
|
|
${checkHost "desko"}
|
|
|
|
${checkHost "lappy"}
|
|
|
|
${checkHost "servo"}
|
|
|
|
${checkHost "moby"}
|
|
|
|
${checkHost "rescue"}
|
|
|
|
echo "desko: $RC_desko"
|
|
|
|
echo "lappy: $RC_lappy"
|
|
|
|
echo "servo: $RC_servo"
|
|
|
|
echo "moby: $RC_moby"
|
|
|
|
echo "rescue: $RC_rescue"
|
|
|
|
exit $(($RC_desko | $RC_lappy | $RC_servo | $RC_moby | $RC_rescue))
|
|
|
|
''
|
2023-09-02 01:25:20 +00:00
|
|
|
);
|
|
|
|
};
|
2023-01-11 10:22:25 +00:00
|
|
|
};
|
|
|
|
|
2023-01-11 05:58:07 +00:00
|
|
|
templates = {
|
2023-04-26 07:35:04 +00:00
|
|
|
env.python-data = {
|
2023-01-11 05:58:07 +00:00
|
|
|
# initialize with:
|
2023-04-26 07:35:04 +00:00
|
|
|
# - `nix flake init -t '/home/colin/dev/nixos/#env.python-data'`
|
2023-01-11 05:58:07 +00:00
|
|
|
# then enter with:
|
|
|
|
# - `nix develop`
|
2023-04-26 07:35:04 +00:00
|
|
|
path = ./templates/env/python-data;
|
2023-01-11 05:58:07 +00:00
|
|
|
description = "python environment for data processing";
|
|
|
|
};
|
2023-04-26 07:35:04 +00:00
|
|
|
pkgs.rust-inline = {
|
2023-04-26 07:20:02 +00:00
|
|
|
# initialize with:
|
2023-04-26 07:35:04 +00:00
|
|
|
# - `nix flake init -t '/home/colin/dev/nixos/#pkgs.rust-inline'`
|
|
|
|
path = ./templates/pkgs/rust-inline;
|
2023-04-26 07:41:08 +00:00
|
|
|
description = "rust package and development environment (inline rust sources)";
|
|
|
|
};
|
|
|
|
pkgs.rust = {
|
|
|
|
# initialize with:
|
|
|
|
# - `nix flake init -t '/home/colin/dev/nixos/#pkgs.rust'`
|
|
|
|
path = ./templates/pkgs/rust;
|
|
|
|
description = "rust package fit to ship in nixpkgs";
|
2023-04-26 07:20:02 +00:00
|
|
|
};
|
2023-05-18 01:31:06 +00:00
|
|
|
pkgs.make = {
|
|
|
|
# initialize with:
|
|
|
|
# - `nix flake init -t '/home/colin/dev/nixos/#pkgs.make'`
|
|
|
|
path = ./templates/pkgs/make;
|
|
|
|
description = "default Makefile-based derivation";
|
|
|
|
};
|
2022-11-30 00:48:27 +00:00
|
|
|
};
|
|
|
|
};
|
2022-05-21 00:07:49 +00:00
|
|
|
}
|
|
|
|
|