Upgrade to the new dream2nix API #26
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
/server/target
|
/packages/server/target
|
||||||
/result
|
/result
|
||||||
|
.dream2nix
|
||||||
|
|
46
flake.nix
46
flake.nix
|
@ -2,7 +2,7 @@
|
||||||
description = "tlater.net web server";
|
description = "tlater.net web server";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
||||||
dream2nix.url = "github:nix-community/dream2nix";
|
dream2nix.url = "github:nix-community/dream2nix";
|
||||||
|
|
||||||
fenix = {
|
fenix = {
|
||||||
|
@ -16,21 +16,28 @@
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
dream2nix,
|
dream2nix,
|
||||||
fenix,
|
fenix,
|
||||||
} @ flake-inputs: let
|
}: 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 = nixpkgs.lib.callPackageWith flake-inputs (import ./nix/packages.nix) {inherit system;};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
fenixPkgs = fenix.packages.${system};
|
||||||
|
ownPkgs = self.packages.${system};
|
||||||
in {
|
in {
|
||||||
packages.${system} = {
|
packages.${system} = dream2nix.lib.importPackages {
|
||||||
server = flakeOutputs.packages.${system}.tlaternet-webserver;
|
projectRoot = ./.;
|
||||||
templates = flakeOutputs.packages.${system}.tlaternet;
|
projectRootFile = "flake.nix";
|
||||||
|
packagesDir = ./packages;
|
||||||
|
packageSets = {
|
||||||
|
nixpkgs = pkgs;
|
||||||
|
fenix = fenixPkgs;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
apps.${system} = {
|
apps.${system} = {
|
||||||
default = let
|
default = let
|
||||||
inherit (self.packages.${system}) server templates;
|
inherit (ownPkgs) server templates;
|
||||||
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
inherit (pkgs) writeShellScript;
|
||||||
in {
|
in {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = builtins.toString (writeShellScript "tlaternet-webserver" ''
|
program = builtins.toString (writeShellScript "tlaternet-webserver" ''
|
||||||
|
@ -39,11 +46,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
update = let
|
update = let
|
||||||
update-script = nixpkgs.legacyPackages.${system}.callPackage ./nix/update.nix {
|
update-script = pkgs.callPackage ./nix/update.nix {inherit self;};
|
||||||
cargo = flakeOutputs.rust-toolchain.cargo;
|
|
||||||
npm = nixpkgs.legacyPackages.${system}.nodePackages_latest.npm;
|
|
||||||
npm-check-updates = self.packages.${system}.templates.dependencies.npm-check-updates;
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "${update-script}/bin/update";
|
program = "${update-script}/bin/update";
|
||||||
|
@ -53,17 +56,9 @@
|
||||||
nixosModules.default = import ./nix/module.nix {inherit self system;};
|
nixosModules.default = import ./nix/module.nix {inherit self system;};
|
||||||
|
|
||||||
devShells.${system} = {
|
devShells.${system} = {
|
||||||
templates = flakeOutputs.devShells.${system}.tlaternet.overrideAttrs (old: {
|
server = pkgs.mkShell {
|
||||||
buildInputs = with nixpkgs.legacyPackages.${system};
|
|
||||||
[
|
|
||||||
yj
|
|
||||||
]
|
|
||||||
++ old.buildInputs;
|
|
||||||
});
|
|
||||||
|
|
||||||
server = nixpkgs.legacyPackages.${system}.mkShell {
|
|
||||||
packages = [
|
packages = [
|
||||||
(flakeOutputs.rust-toolchain.withComponents [
|
(fenixPkgs.stable.withComponents [
|
||||||
"rustc"
|
"rustc"
|
||||||
"cargo"
|
"cargo"
|
||||||
"rustfmt"
|
"rustfmt"
|
||||||
|
@ -73,14 +68,13 @@
|
||||||
"rust-src"
|
"rust-src"
|
||||||
"rust-analysis"
|
"rust-analysis"
|
||||||
])
|
])
|
||||||
fenix.packages.${system}.rust-analyzer
|
fenixPkgs.rust-analyzer
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
checks.${system} = import ./nix/checks {
|
checks.${system} = import ./nix/checks {
|
||||||
inherit self system;
|
inherit self system pkgs;
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
{
|
|
||||||
self,
|
|
||||||
nixpkgs,
|
|
||||||
dream2nix,
|
|
||||||
fenix,
|
|
||||||
system,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (nixpkgs.legacyPackages.${system}) runCommandLocal yj;
|
|
||||||
|
|
||||||
rust-toolchain = fenix.packages.${system}.stable;
|
|
||||||
in
|
|
||||||
dream2nix.lib.makeFlakeOutputs {
|
|
||||||
systems = [system];
|
|
||||||
config.projectRoot = self;
|
|
||||||
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 = {
|
|
||||||
tlaternet-webserver.set-toolchain.overrideRustToolchain = old: {
|
|
||||||
cargo = rust-toolchain.minimalToolchain;
|
|
||||||
rustc = rust-toolchain.minimalToolchain;
|
|
||||||
};
|
|
||||||
|
|
||||||
tlaternet-webserver-deps.set-toolchain.overrideRustToolchain = old: {
|
|
||||||
cargo = rust-toolchain.minimalToolchain;
|
|
||||||
rustc = rust-toolchain.minimalToolchain;
|
|
||||||
};
|
|
||||||
|
|
||||||
tlaternet = {
|
|
||||||
install-only-dist = {
|
|
||||||
installPhase = ''
|
|
||||||
cp -r $nodeModules/tlaternet/dist $out
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
sharp = {
|
|
||||||
add-libvips = {
|
|
||||||
buildInputs = old:
|
|
||||||
old
|
|
||||||
++ (with nixpkgs.legacyPackages.${system}; [
|
|
||||||
vips
|
|
||||||
pkg-config
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// {
|
|
||||||
inherit rust-toolchain;
|
|
||||||
}
|
|
|
@ -10,7 +10,7 @@ echo 'Note: Update the flake inputs with `nix flake update --commit-lockfile *fi
|
||||||
cd "$(git rev-parse --show-toplevel)" || exit
|
cd "$(git rev-parse --show-toplevel)" || exit
|
||||||
|
|
||||||
# Update cargo deps
|
# Update cargo deps
|
||||||
cd server || exit
|
cd packages/server || exit
|
||||||
cargo update
|
cargo update
|
||||||
|
|
||||||
if ! git diff --quiet Cargo.lock Cargo.toml; then
|
if ! git diff --quiet Cargo.lock Cargo.toml; then
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
{
|
{
|
||||||
|
lib,
|
||||||
|
self,
|
||||||
|
system,
|
||||||
writeShellApplication,
|
writeShellApplication,
|
||||||
cargo,
|
|
||||||
git,
|
git,
|
||||||
nix,
|
nix,
|
||||||
npm,
|
|
||||||
npm-check-updates,
|
|
||||||
yq-go,
|
yq-go,
|
||||||
}:
|
}: let
|
||||||
|
selfPackages = self.packages.${system};
|
||||||
|
inherit (selfPackages.server.config.deps) cargo;
|
||||||
|
inherit (selfPackages.templates.config.deps) npm;
|
||||||
|
|
||||||
|
npm-check-updates =
|
||||||
|
(builtins.elemAt (lib.attrValues
|
||||||
|
selfPackages.templates.config.nodejs-granular-v3.deps.npm-check-updates)
|
||||||
|
0)
|
||||||
|
.package-func
|
||||||
|
.result;
|
||||||
|
in
|
||||||
writeShellApplication {
|
writeShellApplication {
|
||||||
name = "update";
|
name = "update";
|
||||||
runtimeInputs = [cargo git nix npm npm-check-updates yq-go];
|
runtimeInputs = [cargo git nix npm npm-check-updates yq-go];
|
||||||
|
|
17
packages/server/default.nix
Normal file
17
packages/server/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{dream2nix, ...}: {
|
||||||
|
imports = [
|
||||||
|
dream2nix.modules.dream2nix.rust-cargo-lock
|
||||||
|
dream2nix.modules.dream2nix.rust-crane
|
||||||
|
];
|
||||||
|
|
||||||
|
deps = {fenix, ...}: {
|
||||||
|
deps.cargo = fenix.stable.minimalToolchain;
|
||||||
|
};
|
||||||
|
|
||||||
|
name = "tlaternet-webserver";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
mkDerivation = {
|
||||||
|
src = ./.;
|
||||||
|
};
|
||||||
|
}
|
44
packages/templates/default.nix
Normal file
44
packages/templates/default.nix
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
dream2nix,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
imports = [
|
||||||
|
dream2nix.modules.dream2nix.nodejs-package-json-v3
|
||||||
|
dream2nix.modules.dream2nix.nodejs-granular-v3
|
||||||
|
];
|
||||||
|
|
||||||
|
deps = {nixpkgs, ...}: {
|
||||||
|
inherit (nixpkgs) pkg-config runCommandLocal rsync vips yj;
|
||||||
|
};
|
||||||
|
|
||||||
|
name = "tlaternet-templates";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
mkDerivation = {
|
||||||
|
src = config.deps.runCommandLocal "source" {nativeBuildInputs = [config.deps.yj];} ''
|
||||||
|
cp -r ${./.} $out/
|
||||||
|
chmod -R u+w $out
|
||||||
|
yj < $out/package.yaml > $out/package.json
|
||||||
|
'';
|
||||||
|
|
||||||
|
# The default phase (which is hidden in `preInstallPhases`) will
|
||||||
|
# copy the full node_modules directory to the output, and symlink
|
||||||
|
# executables and whatnot.
|
||||||
|
#
|
||||||
|
# Since this package's output is static HTML/JS, we do not want
|
||||||
|
# that.
|
||||||
|
preInstallPhases = lib.mkForce [];
|
||||||
|
installPhase = ''
|
||||||
|
cp -r dist $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
nodejs-granular-v3.deps = {
|
||||||
|
sharp."0.28.3".mkDerivation.buildInputs = with config.deps; [
|
||||||
|
vips
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
14899
packages/templates/lock.json
Normal file
14899
packages/templates/lock.json
Normal file
File diff suppressed because it is too large
Load diff
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
@ -1,31 +0,0 @@
|
||||||
# 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"
|
|
|
@ -1,10 +0,0 @@
|
||||||
nix_direnv_watch_file package-lock.json
|
|
||||||
use flake ..#templates
|
|
||||||
|
|
||||||
# Update package.json
|
|
||||||
if ! cmp --silent .checksum-package.yaml <(sha256sum package.yaml); then
|
|
||||||
echo "Updating package.json"
|
|
||||||
unlink ./package.json
|
|
||||||
yj < ./package.yaml > ./package.json
|
|
||||||
sha256sum package.yaml > .checksum-package.yaml
|
|
||||||
fi
|
|
24369
templates/package-lock.json
generated
24369
templates/package-lock.json
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue