Update to NixOS 22.11 #22

Manually merged
tlater merged 4 commits from tlater/update into master 2023-01-05 02:17:42 +00:00
4 changed files with 97 additions and 103 deletions
Showing only changes of commit b2894e4fef - Show all commits

View file

@ -43,11 +43,11 @@
"crane": { "crane": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1670284777, "lastModified": 1670900067,
"narHash": "sha256-JF0pc0s4z/X+Iy+lNHOwUQ8I5bz+q7uX4HrKTNIEj24=", "narHash": "sha256-VXVa+KBfukhmWizaiGiHRVX/fuk66P8dgSFfkVN4/MY=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "2243fb9c872de25cb564a02d324ea6a5b9853052", "rev": "59b31b41a589c0a65e4a1f86b0e5eac68081468b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -89,11 +89,11 @@
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": "pre-commit-hooks"
}, },
"locked": { "locked": {
"lastModified": 1670669673, "lastModified": 1672661134,
"narHash": "sha256-2ESsFsll4n5e3I2e/J4CDzihrX9K+NuWpcsOh7aVxbw=", "narHash": "sha256-WqBUyKeiv+jI11ug+qP0OnZ4nngK6eBRVTGHgdzEGvc=",
"owner": "nix-community", "owner": "nix-community",
"repo": "dream2nix", "repo": "dream2nix",
"rev": "a46b77e2243415ff5eb76b8b35277c0a9b9b072c", "rev": "9f6911c78dcb0832f7fcc955e847db1a5a9ce29a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -133,11 +133,11 @@
"rust-analyzer-src": "rust-analyzer-src_2" "rust-analyzer-src": "rust-analyzer-src_2"
}, },
"locked": { "locked": {
"lastModified": 1670653386, "lastModified": 1672813381,
"narHash": "sha256-n3PWSTkyyNVnP316epb7VXHrVQHIcED1LWFKrkYiKIA=", "narHash": "sha256-PKt6orRiFO19KFKnOhzK26hbFLtimlRNE2dGwrTEhII=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "2745d0c04a278231140125b81996d23fe00d923c", "rev": "eb6583fcd626051c4d284f2fb51cd2659a43e7f6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -293,11 +293,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1670543317, "lastModified": 1672781980,
"narHash": "sha256-4mMR56rtxKr+Gwz399jFr4i76SQZxsLWxxyfQlPXRm0=", "narHash": "sha256-L+yqt2szcp+BFiWoMJCisDsNA5OrpYVW1QSbbS5U8RU=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "7a6a010c3a1d00f8470a5ca888f2f927f1860a19", "rev": "a9eedea7232f5d00f0aca7267efb69a54da1b8a1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -376,11 +376,11 @@
"rust-analyzer-src_2": { "rust-analyzer-src_2": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1670614565, "lastModified": 1672757238,
"narHash": "sha256-9XSIUkTYVO2uYG7sy5wv1mlvqIkLzj02UfHMpf3CzqA=", "narHash": "sha256-BK1njXsjprMT0f+1aQYmZ/ueN9D3Y3wrz9gw4UvieRQ=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "14492043dba29d626ea98667c3c7c0002f75feff", "rev": "a97c71f92d574cb5104e3e1246eb9038d1a214a2",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -16,15 +16,15 @@
nixpkgs, nixpkgs,
dream2nix, dream2nix,
fenix, fenix,
}: let } @ flake-inputs: let
# At the moment, we only deploy to x86_64-linux. Update when we # At the moment, we only deploy to x86_64-linux. Update when we
# care about another platform. # care about another platform.
system = "x86_64-linux"; system = "x86_64-linux";
flakeOutputs = import ./nix/packages.nix {inherit nixpkgs dream2nix fenix system;}; flakeOutputs = nixpkgs.lib.callPackageWith flake-inputs (import ./nix/packages.nix) {inherit system;};
in { in {
packages.${system} = { packages.${system} = {
server = flakeOutputs.server.packages.${system}.default; server = flakeOutputs.packages.${system}.tlaternet-webserver;
templates = flakeOutputs.templates.packages.${system}.default; templates = flakeOutputs.packages.${system}.tlaternet;
}; };
apps.${system}.default = let apps.${system}.default = let
@ -40,7 +40,7 @@
nixosModules.default = import ./nix/module.nix {inherit self system;}; nixosModules.default = import ./nix/module.nix {inherit self system;};
devShells.${system} = { devShells.${system} = {
templates = flakeOutputs.templates.devShells.${system}.default.overrideAttrs (old: { templates = flakeOutputs.devShells.${system}.default.overrideAttrs (old: {
buildInputs = with nixpkgs.legacyPackages.${system}; buildInputs = with nixpkgs.legacyPackages.${system};
[ [
yj yj
@ -50,7 +50,7 @@
server = nixpkgs.legacyPackages.${system}.mkShell { server = nixpkgs.legacyPackages.${system}.mkShell {
packages = [ packages = [
(flakeOutputs.server.rust-toolchain.withComponents [ (flakeOutputs.rust-toolchain.withComponents [
"rustc" "rustc"
"cargo" "cargo"
"rustfmt" "rustfmt"

View file

@ -1,80 +1,41 @@
{ {
self,
nixpkgs, nixpkgs,
dream2nix, dream2nix,
fenix, fenix,
system, system,
}: { ...
server = let }: let
inherit (nixpkgs.legacyPackages.${system}) runCommandLocal yj;
rust-toolchain = fenix.packages.${system}.stable; rust-toolchain = fenix.packages.${system}.stable;
in in
dream2nix.lib.makeFlakeOutputs { dream2nix.lib.makeFlakeOutputs {
systems = [system]; systems = [system];
config.projectRoot = ../server; config.projectRoot = self;
source = ../server; projects = ../projects.toml;
source = runCommandLocal "source" {nativeBuildInputs = [yj];} ''
cp -r ${self} $out/
chmod -R u+w $out
yj < $out/templates/package.yaml > $out/templates/package.json
'';
packageOverrides = { packageOverrides = {
"^.*".set-toolchain.overrideRustToolchain = old: { tlaternet-webserver.set-toolchain.overrideRustToolchain = old: {
cargo = rust-toolchain.minimalToolchain; cargo = rust-toolchain.minimalToolchain;
rustc = rust-toolchain.minimalToolchain; rustc = rust-toolchain.minimalToolchain;
}; };
};
} tlaternet-webserver-deps.set-toolchain.overrideRustToolchain = old: {
// { cargo = rust-toolchain.minimalToolchain;
inherit rust-toolchain; rustc = rust-toolchain.minimalToolchain;
}; };
templates = let
inherit (nixpkgs.legacyPackages.${system}) runCommandLocal yj;
in
dream2nix.lib.makeFlakeOutputs {
systems = [system];
config.projectRoot = ../templates;
# Generate `package.json` from `package.yaml`, since the nodejs
# ecosystem doesn't support yaml.
source = runCommandLocal "templates" {nativeBuildInputs = [yj];} ''
cp -r ${../templates} $out/
chmod u+w $out
yj < ${../templates/package.yaml} > $out/package.json
'';
packageOverrides = {
tlaternet = { tlaternet = {
add-build-script = { install-only-dist = {
# Dream2nix' built-in install script assumes this is just
# a usual npm package and will install it in
# `node_modules`.
#
# Parcel will detect this, and completely break all
# configuration. Furthermore, we don't actually want to
# install this as if it was an npm library.
#
# The easiest way to fix this is just to rename the
# top-level directory.
preBuild = ''
# Rename top-level directory so parcel doesn't think we're in a
# node_module
mv ../../node_modules ../../top-level
# Rewrite $PATH and co. to use the new path.
export PATH=''${PATH//lib\/node_modules\/.bin/lib\/top-level\/.bin}
export NODE_PATH=''${NODE_PATH//lib\/node_modules/lib\/top-level}
'';
installPhase = '' installPhase = ''
# For some reason, dream2nix builds in the out directory. Don't ask cp -r $nodeModules/tlaternet/dist $out
# me, I don't know either.
# First, go to a sane directory and back up our actual build output
mv dist /build/dist
cd /build
# Then, delete everything currently in $out
chmod -R u+rwx $out
rm -r $out
# Finally, actually install our output
mv dist $out
''; '';
}; };
}; };
@ -90,5 +51,7 @@
}; };
}; };
}; };
}; }
// {
inherit rust-toolchain;
} }

31
projects.toml Normal file
View file

@ -0,0 +1,31 @@
# projects.toml file describing inputs for dream2nix
#
# To re-generate this file, run:
# nix run .#detect-projects $source
# ... where `$source` points to the source of your project.
#
# If the local flake is unavailable, alternatively execute the app from the
# upstream dream2nix flake:
# nix run github:nix-community/dream2nix#detect-projects $source
[tlaternet]
name = "tlaternet"
relPath = "templates"
subsystem = "nodejs"
translator = "package-lock"
translators = [ "package-lock", "package-json",]
[tlaternet.subsystemInfo]
[tlaternet-webserver]
name = "tlaternet-webserver"
relPath = "server"
subsystem = "rust"
translator = "cargo-lock"
translators = [ "cargo-lock", "cargo-toml",]
[tlaternet-webserver.subsystemInfo]
workspaceMembers = []
[[tlaternet-webserver.subsystemInfo.crates]]
name = "tlaternet-webserver"
relPath = "server"
version = "0.1.0"