first commit

This commit is contained in:
Mans Ziesel 2024-01-23 20:13:51 +01:00
commit 6efcf92100
10 changed files with 236 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/mzsite
/result
node_modules

3
Makefile Normal file
View File

@ -0,0 +1,3 @@
proccess-css:
npx tailwindcss -i ./embedded/static/css/input.css -o ./embedded/static/css/style.css --watch

8
cmd/server/main.go Normal file
View File

@ -0,0 +1,8 @@
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
fmt.Println("Hello, World!")
}

22
default.nix Normal file
View File

@ -0,0 +1,22 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, buildGoApplication ? pkgs.buildGoApplication
}:
buildGoApplication {
pname = "server";
version = "0.1";
pwd = ./.;
src = ./.;
modules = ./gomod2nix.toml;
subPackages = [ "cmd/server" ];
}

85
flake.lock Normal file
View File

@ -0,0 +1,85 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gomod2nix": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1705314449,
"narHash": "sha256-yfQQ67dLejP0FLK76LKHbkzcQqNIrux6MFe32MMFGNQ=",
"owner": "nix-community",
"repo": "gomod2nix",
"rev": "30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "gomod2nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1705856552,
"narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"gomod2nix": "gomod2nix",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

48
flake.nix Normal file
View File

@ -0,0 +1,48 @@
{
description = "A basic gomod2nix flake";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.gomod2nix.url = "github:nix-community/gomod2nix";
inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
# This has no effect on other platforms.
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
in
{
packages.default = callPackage ./. {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
};
packages.docker = let
bin = self.packages.${system}.default;
in pkgs.dockerTools.buildImage {
name = "git.mzsl.nl/mans/goshare";
tag = "latest";
fromImageName = "alpine";
created = "now";
# contents = [ bin ];
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ bin ];
pathsToLink = [ "/bin" ];
};
config.Cmd = [ "/bin/server" ];
};
devShells.default = callPackage ./shell.nix {
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
};
})
);
}

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module git.mzsl.nl/mans/goshare
go 1.21

3
gomod2nix.toml Normal file
View File

@ -0,0 +1,3 @@
schema = 3
[mod]

37
schema/schema.go Normal file
View File

@ -0,0 +1,37 @@
package schema
import "time"
type ShareType = int
const (
ShareDrop = iota
ShareSendSingle
ShareSendMultiple
)
type MimeType = int
const (
MimeTypeText = iota
)
type Share struct {
ShareId int
ShareType ShareType
CreatedAt time.Time
ValidUntil time.Time
PasswordHash string
ManagementToken string
Enabled bool
}
type ShareFile struct {
ShareId int
Filename string
Mimetype MimeType
FileHash string
UploadedAt time.Time
Deleted bool
DownloadCount int
}

24
shell.nix Normal file
View File

@ -0,0 +1,24 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, mkGoEnv ? pkgs.mkGoEnv
, gomod2nix ? pkgs.gomod2nix
}:
let
goEnv = mkGoEnv { pwd = ./.; };
in
pkgs.mkShell {
packages = [
goEnv
gomod2nix
];
}