fix: Add nix shell and migrate to slnx/bun

This commit is contained in:
2026-01-06 10:55:14 +01:00
parent 24eeb420f2
commit 6483f41ee5
14 changed files with 1484 additions and 10151 deletions

View File

@@ -18,8 +18,8 @@ let versionFile = Path.getFullName ".version"
Target.create "Clean" (fun _ -> Shell.cleanDir distPath)
Target.create "InstallClient" (fun _ ->
run npm "install" "."
run dotnet "tool restore" ".")
run bun "install" "."
)
Target.create "Bundle" (fun _ -> run dotnet $"publish -c Release -o {distPath}" srcPath)

View File

@@ -71,16 +71,16 @@ let createProcess exe arg dir =
|> CreateProcess.ensureExitCode
let dotnet = createProcess "dotnet"
let npm =
let npmPath =
match ProcessUtils.tryFindFileOnPath "npm" with
let bun =
let bunPath =
match ProcessUtils.tryFindFileOnPath "bun" with
| Some path -> path
| None ->
"npm was not found in path. Please install it and make sure it's available from your path. "
"bun was not found in path. Please install it and make sure it's available from your path. "
+ "See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
|> failwith
createProcess npmPath
createProcess bunPath
let run proc arg dir = proc arg dir |> Proc.run |> ignore

View File

@@ -7,26 +7,38 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
[*.js]
indent_size = 2
max_line_length = 80
[*.scss]
indent_size = 2
max_line_length = 80
[*.nix]
indent_size = 2
max_line_length= 80
[*.scss]
indent_size = 2
max_line_length = 80
[*.fs]
max_line_length=120
# Feliz style
fsharp_single_argument_web_mode=true
fsharp_space_before_colon=false
fsharp_max_if_then_else_short_width=60
fsharp_max_infix_operator_expression=50
fsharp_max_record_width=70
fsharp_max_record_number_of_items=1
fsharp_max_array_or_list_width=70
fsharp_max_array_or_list_number_of_items=1
fsharp_max_value_binding_width=70
fsharp_max_function_binding_width=40
fsharp_max_dot_get_expression_width=50
fsharp_multiline_block_brackets_on_same_column=true
fsharp_newline_between_type_definition_and_members=false
fsharp_max_elmish_width=40
fsharp_align_function_signature_to_indentation=false
fsharp_alternative_long_member_definitions=false
fsharp_multi_line_lambda_closing_newline=false
fsharp_disable_elmish_syntax=false
fsharp_keep_indent_in_branch=false
fsharp_blank_lines_around_nested_multiline_expressions=false
max_line_length= 120
fsharp_max_if_then_else_short_width = 60
fsharp_max_infix_operator_expression = 80
fsharp_space_before_uppercase_invocation = true
fsharp_blank_lines_around_nested_multiline_expressions = false
fsharp_newline_between_type_definition_and_members = false
fsharp_multiline_bracket_style = stroustrup
fsharp_multi_line_lambda_closing_newline = true
fsharp_array_or_list_multiline_formatter = character_width
fsharp_max_array_or_list_width = 70
fsharp_max_array_or_list_number_of_items = 3
fsharp_record_multiline_formatter = number_of_items
fsharp_max_record_number_of_items = 3
fsharp_max_record_width = 70

12
.envrc Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# the shebang is ignored, but nice for editors
watch_file nix/sources.json
# Load .env file if it exists
dotenv_if_exists
# Set npins path
export NPINS_DIRECTORY="nix"
# Load environment
use nix

3
.gitignore vendored
View File

@@ -18,3 +18,6 @@ build/
*.db
build.fsx.lock
_*.yaml
# nix
result
.direnv/

View File

@@ -1,78 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8FB8B894-4C13-4AD1-9D61-1DB30538F6D0}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
LICENSE = LICENSE
Dockerfile = Dockerfile
.gitlab-ci.yml = .gitlab-ci.yml
EndProjectSection
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "Build.fsproj", "{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "src", "src/Cancan.fsproj", "{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "test", "test\Tests.fsproj", "{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x64.ActiveCfg = Debug|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x64.Build.0 = Debug|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x86.ActiveCfg = Debug|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x86.Build.0 = Debug|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|Any CPU.Build.0 = Release|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x64.ActiveCfg = Release|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x64.Build.0 = Release|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x86.ActiveCfg = Release|Any CPU
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x86.Build.0 = Release|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x64.ActiveCfg = Debug|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x64.Build.0 = Debug|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x86.ActiveCfg = Debug|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x86.Build.0 = Debug|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|Any CPU.Build.0 = Release|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x64.ActiveCfg = Release|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x64.Build.0 = Release|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x86.ActiveCfg = Release|Any CPU
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x86.Build.0 = Release|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x64.ActiveCfg = Debug|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x64.Build.0 = Debug|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x86.ActiveCfg = Debug|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x86.Build.0 = Debug|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|Any CPU.Build.0 = Release|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x64.ActiveCfg = Release|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x64.Build.0 = Release|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x86.ActiveCfg = Release|Any CPU
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F7486515-1BC3-4F9C-BE05-05466043A1AA}
EndGlobalSection
EndGlobal

16
Cancan.slnx Normal file
View File

@@ -0,0 +1,16 @@
<Solution>
<Configurations>
<Platform Name="Any CPU" />
<Platform Name="x64" />
<Platform Name="x86" />
</Configurations>
<Folder Name="/Solution Items/">
<File Path=".gitlab-ci.yml" />
<File Path="Dockerfile" />
<File Path="LICENSE" />
<File Path="README.md" />
</Folder>
<Project Path="Build.fsproj" />
<Project Path="src/Cancan.fsproj" />
<Project Path="test/Tests.fsproj" />
</Solution>

21
LICENSE
View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2020 Serit Tromsø AS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1218
bun.lock Normal file

File diff suppressed because it is too large Load Diff

146
nix/default.nix Normal file
View File

@@ -0,0 +1,146 @@
/*
This file is provided under the MIT licence:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range =
first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";
# If the environment variable NPINS_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
# (Taken from Niv for compatibility)
mayOverride =
name: path:
let
envVarName = "NPINS_OVERRIDE_${saneName}";
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
ersatz = builtins.getEnv envVarName;
in
if ersatz == "" then
path
else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
if builtins.substring 0 1 ersatz == "/" then
/. + ersatz
else
/. + builtins.getEnv "PWD" + "/${ersatz}"
);
mkSource =
name: spec:
assert spec ? type;
let
path =
if spec.type == "Git" then
mkGitSource spec
else if spec.type == "GitRelease" then
mkGitSource spec
else if spec.type == "PyPi" then
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else if spec.type == "Tarball" then
mkTarballSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = mayOverride name path; };
mkGitSource =
{
repository,
revision,
url ? null,
submodules,
hash,
branch ? null,
...
}:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null && !submodules then
builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
}
else
let
url =
if repository.type == "Git" then
repository.url
else if repository.type == "GitHub" then
"https://github.com/${repository.owner}/${repository.repo}.git"
else if repository.type == "GitLab" then
"${repository.server}/${repository.repo_path}.git"
else
throw "Unrecognized repository type ${repository.type}";
urlToName =
url: rev:
let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;
short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
in
"${if matched == null then "source" else builtins.head matched}${appendShort}";
name = urlToName url revision;
in
builtins.fetchGit {
rev = revision;
inherit name;
# hash = hash;
inherit url submodules;
};
mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};
mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
};
mkTarballSource =
{
url,
locked_url ? url,
hash,
...
}:
builtins.fetchTarball {
url = locked_url;
sha256 = hash;
};
in
if version == 5 then
builtins.mapAttrs mkSource data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"

11
nix/sources.json Normal file
View File

@@ -0,0 +1,11 @@
{
"pins": {
"nixpkgs": {
"type": "Channel",
"name": "nixpkgs-unstable",
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre921317.16c7794d0a28/nixexprs.tar.xz",
"hash": "1p3lj604zhrw1lzw23bagmqazhd3ynigp61kqdxjaic2lgx9xa0v"
}
},
"version": 5
}

10009
package-lock.json generated

File diff suppressed because it is too large Load Diff

23
shell.nix Normal file
View File

@@ -0,0 +1,23 @@
{
sources ? import ./nix,
pkgs ? import sources.nixpkgs { },
}:
let
dotnet-sdk = pkgs.dotnetCorePackages.sdk_9_0;
in
pkgs.mkShell rec {
packages = with pkgs; [
dotnet-sdk
fsautocomplete
fantomas
bun
];
buildInputs = [
pkgs.netcdf
];
DOTNET_ROOT = "${dotnet-sdk}/share/dotnet";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
}

View File

@@ -14,9 +14,9 @@
},
"FSharp.Core": {
"type": "Direct",
"requested": "[9.0.201, )",
"resolved": "9.0.201",
"contentHash": "Ozq4T0ISTkqTYJ035XW/JkdDDaXofbykvfyVwkjLSqaDZ/4uNXfpf92cjcMI9lf9CxWqmlWHScViPh/4AvnWcw=="
"requested": "[9.0.303, )",
"resolved": "9.0.303",
"contentHash": "6JlV8aD8qQvcmfoe/PMOxCHXc0uX4lR23u0fAyQtnVQxYULLoTZgwgZHSnRcuUHOvS3wULFWcwdnP1iwslH60g=="
},
"FSharp.Data": {
"type": "Direct",
@@ -58,8 +58,8 @@
"Oceanbox.FvcomKit": {
"type": "Direct",
"requested": "[5.12.0, )",
"resolved": "5.12.0",
"contentHash": "78qkFpO2819Ddg6hYqRKXwCj2/ZBqrNKJ3536Q9R+4lx7dfMox97VPcpHviPRb/NsFG1M60TaYpm2DxuZclPaA==",
"resolved": "5.13.0",
"contentHash": "6uVL3fLhRf4OU1hWygGpVex4pI5YB+GaWrKZUgoL/LkGmdFv0qU8Y7v+meHNM3E9bjR7xKinCVfrw5SXsF6C8g==",
"dependencies": {
"FSharp.Core": "9.0.201",
"FSharp.Data": "6.4.1",
@@ -68,8 +68,8 @@
"KDTree": "1.4.1",
"MathNet.Numerics.FSharp": "5.0.0",
"MessagePack": "3.1.3",
"Oceanbox.SDSLite": "2.8.0",
"ProjNet.FSharp": "5.2.0",
"SDSlite.Oceanbox": "2.7.3",
"Serilog": "4.2.0",
"Serilog.Sinks.Console": "6.0.0",
"Serilog.Sinks.Seq": "9.0.0",
@@ -268,6 +268,14 @@
"resolved": "13.0.1",
"contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A=="
},
"Oceanbox.SDSLite": {
"type": "Transitive",
"resolved": "2.8.0",
"contentHash": "DzMcnywHhtmLVDZSVCZq6Mqq+SIm4snGRYgquho9xZSyEq5RhBkLdSa5k59m7o24FGZyt75DGpElN9p+dezU7Q==",
"dependencies": {
"DynamicInterop": "0.9.1"
}
},
"ProjNET": {
"type": "Transitive",
"resolved": "2.0.0",
@@ -277,14 +285,6 @@
"System.Numerics.Vectors": "4.5.0"
}
},
"SDSLite.Oceanbox": {
"type": "Transitive",
"resolved": "2.7.3",
"contentHash": "tmTPsEUmQhwaCzHwuSw7he2FfjcVpZ/Sy2ewfTwm1IKnwOZazKouTS5t4LNUpaGtjK1o/gdfz1b+0KxXnUl97g==",
"dependencies": {
"DynamicInterop": "0.9.1"
}
},
"Serilog.Sinks.File": {
"type": "Transitive",
"resolved": "6.0.0",