Compare commits

..

No commits in common. "40e0946201d5df0d526ca2e2fe3f8c9ed4d0cab0" and "c573a6f81827594ceeffbfa058659e2fc20e4a1e" have entirely different histories.

60 changed files with 24783 additions and 15063 deletions

3
.gitignore vendored
View file

@ -1,3 +1,2 @@
/packages/server/target
/server/target
/result
.dream2nix

View file

@ -1,17 +1,80 @@
{
"nodes": {
"all-cabal-json": {
"flake": false,
"locked": {
"lastModified": 1665552503,
"narHash": "sha256-r14RmRSwzv5c+bWKUDaze6pXM7nOsiz1H8nvFHJvufc=",
"owner": "nix-community",
"repo": "all-cabal-json",
"rev": "d7c0434eebffb305071404edcf9d5cd99703878e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "hackage",
"repo": "all-cabal-json",
"type": "github"
}
},
"crane": {
"flake": false,
"locked": {
"lastModified": 1681175776,
"narHash": "sha256-7SsUy9114fryHAZ8p1L6G6YSu7jjz55FddEwa2U8XZc=",
"owner": "ipetkov",
"repo": "crane",
"rev": "445a3d222947632b5593112bb817850e8a9cf737",
"type": "github"
},
"original": {
"owner": "ipetkov",
"ref": "v0.12.1",
"repo": "crane",
"type": "github"
}
},
"devshell": {
"flake": false,
"locked": {
"lastModified": 1663445644,
"narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=",
"owner": "numtide",
"repo": "devshell",
"rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"dream2nix": {
"inputs": {
"all-cabal-json": "all-cabal-json",
"crane": "crane",
"devshell": "devshell",
"drv-parts": "drv-parts",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"flake-utils-pre-commit": "flake-utils-pre-commit",
"ghc-utils": "ghc-utils",
"gomod2nix": "gomod2nix",
"mach-nix": "mach-nix",
"nix-pypi-fetcher": "nix-pypi-fetcher",
"nixpkgs": "nixpkgs",
"purescript-overlay": "purescript-overlay",
"pyproject-nix": "pyproject-nix"
"nixpkgsV1": "nixpkgsV1",
"poetry2nix": "poetry2nix",
"pre-commit-hooks": "pre-commit-hooks",
"pruned-racket-catalog": "pruned-racket-catalog"
},
"locked": {
"lastModified": 1702457430,
"narHash": "sha256-8NQiXtYCOiC7XFayy6GPGDudCBrPROry3mfWjpdVj5g=",
"lastModified": 1686064783,
"narHash": "sha256-qyptOk4vDut2JkRMJ+815eJNqqd8gIfjpz3l4WCCtMY=",
"owner": "nix-community",
"repo": "dream2nix",
"rev": "262198033e23e9ee832f0cc8133d38f07598f555",
"rev": "0c064fa9dd025069cc215b0a8b4eb5ea734aceb0",
"type": "github"
},
"original": {
@ -20,6 +83,35 @@
"type": "github"
}
},
"drv-parts": {
"inputs": {
"flake-compat": [
"dream2nix",
"flake-compat"
],
"flake-parts": [
"dream2nix",
"flake-parts"
],
"nixpkgs": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1680698112,
"narHash": "sha256-FgnobN/DvCjEsc0UAZEAdPLkL4IZi2ZMnu2K2bUaElc=",
"owner": "davhau",
"repo": "drv-parts",
"rev": "e8c2ec1157dc1edb002989669a0dbd935f430201",
"type": "github"
},
"original": {
"owner": "davhau",
"repo": "drv-parts",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
@ -28,11 +120,11 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1704003651,
"narHash": "sha256-bA3d4E1CX5G7TVbKwJOm9jZfVOGOPp6u5CKEUzNsE8E=",
"lastModified": 1686637310,
"narHash": "sha256-sGfKyioVsxQppDM0eDO62wtFiz+bZOD0cBMMIEjqn4I=",
"owner": "nix-community",
"repo": "fenix",
"rev": "c6d82e087ac96f24b90c5787a17e29a72566c2b4",
"rev": "6fbeedcd2fc1fba77152e13fd7492824d77a4060",
"type": "github"
},
"original": {
@ -41,74 +133,223 @@
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1675933616,
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils-pre-commit": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"ghc-utils": {
"flake": false,
"locked": {
"lastModified": 1662774800,
"narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=",
"ref": "refs/heads/master",
"rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea",
"revCount": 1072,
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
},
"original": {
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
}
},
"gomod2nix": {
"flake": false,
"locked": {
"lastModified": 1627572165,
"narHash": "sha256-MFpwnkvQpauj799b4QTBJQFEddbD02+Ln5k92QyHOSk=",
"owner": "tweag",
"repo": "gomod2nix",
"rev": "67f22dd738d092c6ba88e420350ada0ed4992ae8",
"type": "github"
},
"original": {
"owner": "tweag",
"repo": "gomod2nix",
"type": "github"
}
},
"mach-nix": {
"flake": false,
"locked": {
"lastModified": 1634711045,
"narHash": "sha256-m5A2Ty88NChLyFhXucECj6+AuiMZPHXNbw+9Kcs7F6Y=",
"owner": "DavHau",
"repo": "mach-nix",
"rev": "4433f74a97b94b596fa6cd9b9c0402104aceef5d",
"type": "github"
},
"original": {
"id": "mach-nix",
"type": "indirect"
}
},
"nix-pypi-fetcher": {
"flake": false,
"locked": {
"lastModified": 1669065297,
"narHash": "sha256-UStjXjNIuIm7SzMOWvuYWIHBkPUKQ8Id63BMJjnIDoA=",
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"rev": "a9885ac6a091576b5195d547ac743d45a2a615ac",
"type": "github"
},
"original": {
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1702272962,
"narHash": "sha256-D+zHwkwPc6oYQ4G3A1HuadopqRwUY/JkMwHz1YF7j4Q=",
"lastModified": 1665580254,
"narHash": "sha256-hO61XPkp1Hphl4HGNzj1VvDH5URt7LI6LaY/385Eul4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e97b3e4186bcadf0ef1b6be22b8558eab1cdeb5d",
"rev": "f634d427b0224a5f531ea5aa10c3960ba6ec5f0f",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgsV1": {
"locked": {
"lastModified": 1678500271,
"narHash": "sha256-tRBLElf6f02HJGG0ZR7znMNFv/Uf7b2fFInpTHiHaSE=",
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"rev": "5eb98948b66de29f899c7fe27ae112a47964baf8",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.11",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1703900474,
"narHash": "sha256-Zu+chYVYG2cQ4FCbhyo6rc5Lu0ktZCjRbSPE0fDgukI=",
"lastModified": 1686513595,
"narHash": "sha256-H3JNqj7TEiMx5rd8lRiONvgFZvmf3kmwHI2umDdqgFY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9dd7699928e26c3c00d5d46811f1358524081062",
"rev": "bb8b5735d6f7e06b9ddd27de115b0600c1ffbdb4",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.11",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"purescript-overlay": {
"poetry2nix": {
"flake": false,
"locked": {
"lastModified": 1666918719,
"narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "289efb187123656a116b915206e66852f038720e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "1.36.0",
"repo": "poetry2nix",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-utils": [
"dream2nix",
"flake-utils-pre-commit"
],
"nixpkgs": [
"dream2nix",
"nixpkgs"
],
"slimlock": "slimlock"
]
},
"locked": {
"lastModified": 1696022621,
"narHash": "sha256-eMjFmsj2G1E0Q5XiibUNgFjTiSz0GxIeSSzzVdoN730=",
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"rev": "047c7933abd6da8aa239904422e22d190ce55ead",
"lastModified": 1646153636,
"narHash": "sha256-AlWHMzK+xJ1mG267FdT8dCq/HvLCA6jwmx2ZUy5O8tY=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "b6bc0b21e1617e2b07d8205e7fae7224036dfa4b",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"pyproject-nix": {
"pruned-racket-catalog": {
"flake": false,
"locked": {
"lastModified": 1702448246,
"narHash": "sha256-hFg5s/hoJFv7tDpiGvEvXP0UfFvFEDgTdyHIjDVHu1I=",
"owner": "davhau",
"repo": "pyproject.nix",
"rev": "5a06a2697b228c04dd2f35659b4b659ca74f7aeb",
"lastModified": 1672537287,
"narHash": "sha256-SuOvXVcLfakw18oJB/PuRMyvGyGG1+CQD3R+TGHIv44=",
"owner": "nix-community",
"repo": "pruned-racket-catalog",
"rev": "c8b89557fb53b36efa2ee48a769c7364df0f6262",
"type": "github"
},
"original": {
"owner": "davhau",
"ref": "dream2nix",
"repo": "pyproject.nix",
"owner": "nix-community",
"ref": "catalog",
"repo": "pruned-racket-catalog",
"type": "github"
}
},
@ -122,11 +363,11 @@
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1703965384,
"narHash": "sha256-3iyouqkBvhh/E48TkBlt4JmmcIEyfQwY7pokKBx9WNg=",
"lastModified": 1686586902,
"narHash": "sha256-+zfBFBmUxWutKbhdntI9uvF4D5Rh7BhcByM2l+ReyTw=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "e872f5085cf5b0e44558442365c1c033d486eff2",
"rev": "1f1fe81f0db301124b3026bd2940294526cdd852",
"type": "github"
},
"original": {
@ -135,28 +376,6 @@
"repo": "rust-analyzer",
"type": "github"
}
},
"slimlock": {
"inputs": {
"nixpkgs": [
"dream2nix",
"purescript-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688610262,
"narHash": "sha256-Wg0ViDotFWGWqKIQzyYCgayeH8s4U1OZcTiWTQYdAp4=",
"owner": "thomashoneyman",
"repo": "slimlock",
"rev": "b5c6cdcaf636ebbebd0a1f32520929394493f1a6",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "slimlock",
"type": "github"
}
}
},
"root": "root",

View file

@ -2,7 +2,7 @@
description = "tlater.net web server";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
dream2nix.url = "github:nix-community/dream2nix";
fenix = {
@ -16,28 +16,21 @@
nixpkgs,
dream2nix,
fenix,
}: let
} @ flake-inputs: let
# At the moment, we only deploy to x86_64-linux. Update when we
# care about another platform.
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
fenixPkgs = fenix.packages.${system};
ownPkgs = self.packages.${system};
flakeOutputs = nixpkgs.lib.callPackageWith flake-inputs (import ./nix/packages.nix) {inherit system;};
in {
packages.${system} = dream2nix.lib.importPackages {
projectRoot = ./.;
projectRootFile = "flake.nix";
packagesDir = ./packages;
packageSets = {
nixpkgs = pkgs;
fenix = fenixPkgs;
};
packages.${system} = {
server = flakeOutputs.packages.${system}.tlaternet-webserver;
templates = flakeOutputs.packages.${system}.tlaternet;
};
apps.${system} = {
default = let
inherit (ownPkgs) server templates;
inherit (pkgs) writeShellScript;
inherit (self.packages.${system}) server templates;
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
in {
type = "app";
program = builtins.toString (writeShellScript "tlaternet-webserver" ''
@ -46,7 +39,11 @@
};
update = let
update-script = pkgs.callPackage ./nix/update.nix {inherit self;};
update-script = nixpkgs.legacyPackages.${system}.callPackage ./nix/update.nix {
cargo = flakeOutputs.rust-toolchain.cargo;
npm = nixpkgs.legacyPackages.${system}.nodePackages_latest.npm;
npm-check-updates = self.packages.${system}.templates.dependencies.npm-check-updates;
};
in {
type = "app";
program = "${update-script}/bin/update";
@ -56,9 +53,17 @@
nixosModules.default = import ./nix/module.nix {inherit self system;};
devShells.${system} = {
server = pkgs.mkShell {
templates = flakeOutputs.devShells.${system}.tlaternet.overrideAttrs (old: {
buildInputs = with nixpkgs.legacyPackages.${system};
[
yj
]
++ old.buildInputs;
});
server = nixpkgs.legacyPackages.${system}.mkShell {
packages = [
(fenixPkgs.stable.withComponents [
(flakeOutputs.rust-toolchain.withComponents [
"rustc"
"cargo"
"rustfmt"
@ -68,13 +73,14 @@
"rust-src"
"rust-analysis"
])
fenixPkgs.rust-analyzer
fenix.packages.${system}.rust-analyzer
];
};
};
checks.${system} = import ./nix/checks {
inherit self system pkgs;
inherit self system;
pkgs = nixpkgs.legacyPackages.${system};
};
};
}

57
nix/packages.nix Normal file
View file

@ -0,0 +1,57 @@
{
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;
}

View file

@ -10,7 +10,7 @@ echo 'Note: Update the flake inputs with `nix flake update --commit-lockfile *fi
cd "$(git rev-parse --show-toplevel)" || exit
# Update cargo deps
cd packages/server || exit
cd server || exit
cargo update
if ! git diff --quiet Cargo.lock Cargo.toml; then

View file

@ -1,25 +1,14 @@
{
lib,
self,
system,
writeShellApplication,
cargo,
git,
nix,
npm,
npm-check-updates,
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 {
name = "update";
runtimeInputs = [cargo git nix npm npm-check-updates yq-go];
text = builtins.readFile ./scripts/update.sh;
}
}:
writeShellApplication {
name = "update";
runtimeInputs = [cargo git nix npm npm-check-updates yq-go];
text = builtins.readFile ./scripts/update.sh;
}

View file

@ -1,17 +0,0 @@
{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 = ./.;
};
}

View file

@ -1,44 +0,0 @@
{
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
];
};
}

File diff suppressed because it is too large Load diff

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"

10
templates/.envrc Normal file
View file

@ -0,0 +1,10 @@
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 Normal file

File diff suppressed because it is too large Load diff

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB