meta: refactor repository

This commit is contained in:
Artur Manuel 2025-03-26 15:08:13 +00:00
commit 599fe1903f
Signed by: amadaluzia
SSH key fingerprint: SHA256:Zwg7gBuZyaG48ucAZneJwltiXu0+tJb7c3lYt9AYlLg
28 changed files with 276 additions and 136 deletions

1
templates/go/.envrc Normal file
View file

@ -0,0 +1 @@
use flake .#

View file

@ -18,7 +18,23 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},

View file

@ -1,38 +1,27 @@
{
description = "Go flake template";
description = "CHANGE DESC";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
};
outputs = {
self,
nixpkgs,
}: let
allSystems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = f:
nixpkgs.lib.genAttrs allSystems (system:
f {
pkgs = import nixpkgs {inherit system;};
inherit system;
});
in {
packages = forAllSystems ({
pkgs,
system,
}: {
default = pkgs.callPackage ./nix/package.nix {};
go-app = self.packages.${system}.default;
});
outputs = { self, nixpkgs, systems, }:
let
inherit (nixpkgs) lib;
pkgsFor = nixpkgs.legacyPackages;
forAllSystems = f:
lib.genAttrs (import systems) (system: f system pkgsFor.${system});
in {
packages = forAllSystems (system: pkgs: {
default = pkgs.callPackage ./flake/package.nix { };
CHANGE_NAME = self.packages.${system}.default;
});
devShells = forAllSystems ({
pkgs,
system,
}: {
default = pkgs.callPackage ./nix/shell.nix {inherit (self.packages.${system}) go-app;};
});
};
devShells = forAllSystems
(_: pkgs: { default = pkgs.callPackage ./flake/shell.nix { }; });
formatter =
forAllSystems (_: pkgs: pkgs.callPackage ./flake/formatter.nix { });
};
}

View file

@ -0,0 +1,10 @@
{ writeShellApplication, fd, nixfmt, deadnix, statix, go }:
writeShellApplication {
name = "linter";
runtimeInputs = [ fd nixfmt deadnix statix go ];
text = ''
fd -e nix -X nixfmt {} \; -X deadnix -e {} \;
fd -e nix -x statix fix {} \;
fd -e rs -X go fmt {} \; -X go vet {} \;
'';
}

View file

@ -1,9 +1,8 @@
{ buildGoModule }:
let
pname = "go-app";
version = "0.1.0";
in
buildGoModule {
pname = "CHANGE_ME";
version = "CHANGE_VER";
in buildGoModule {
inherit pname version;
src = ../.;
vendorHash = null;

View file

@ -0,0 +1,9 @@
{ mkShell, go, gopls, go-tools }:
mkShell {
name = "go";
packages = [
go
gopls
go-tools
];
}

View file

@ -1,3 +1,3 @@
module codeberg.org/amadaluzia/go-app
module codeberg.org/amadaluzia/CHANGE_ME
go 1.22.5

View file

@ -29,14 +29,14 @@ func GetResponse() (*http.Response, error) {
for attempts != 0 {
res, err = http.Get(url)
if err != nil {
fmt.Fprintln(os.Stderr, "Error encountered... trying again...")
fmt.Fprintln(os.Stderr, "error encountered... trying again")
time.Sleep(2 * time.Second)
attempts--
continue
}
if res.StatusCode != 200 {
fmt.Fprintf(os.Stderr, "API returned but a 200, so I will be running this again in a few seconds.")
fmt.Fprintf(os.Stderr, "the API returned but a 200, so I will be running this again in a few seconds")
time.Sleep(2 * time.Second)
attempts--
continue
@ -52,7 +52,7 @@ func GetResponse() (*http.Response, error) {
}
if res.StatusCode != 200 {
return nil, errors.New("Gave up attempting to get 200.")
return nil, errors.New("gave up attempting to get 200")
}
return res, nil
@ -73,10 +73,8 @@ func GetBodyFromResponse(res *http.Response) ([]byte, error) {
func NewQuoteFromBody(body []byte) (Quote, error) {
var quote Quote
var err error
err = json.Unmarshal(body, &quote)
if err != nil {
if err := json.Unmarshal(body, &quote); err != nil {
return Quote{}, err
}

View file

@ -1,11 +0,0 @@
{ mkShell, go, go-app, gopls, go-tools, gotools }:
mkShell {
name = "Gopherborough";
inputsFrom = [ go-app ];
buildInputs = [
go
gopls
go-tools
gotools
];
}

1
templates/nim/.envrc Normal file
View file

@ -0,0 +1 @@
use flake .#

View file

@ -0,0 +1,14 @@
# Package
version = "CHANGE_VER"
author = "Artur Manuel"
description = "CHANGE DESC"
license = "BSD-3-Clause"
srcDir = "src"
installExt = @["nim"]
bin = @["nim"]
# Dependencies
requires "nim >= 2.0.12"

43
templates/nim/flake.lock generated Normal file
View file

@ -0,0 +1,43 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1742669843,
"narHash": "sha256-G5n+FOXLXcRx+3hCJ6Rt6ZQyF1zqQ0DL0sWAMn2Nk0w=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1e5b653dff12029333a6546c11e108ede13052eb",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"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
}

32
templates/nim/flake.nix Normal file
View file

@ -0,0 +1,32 @@
{
description = "CHANGE DESC";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
};
outputs =
inputs@{ self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
pkgsFor = nixpkgs.legacyPackages;
eachSystem = f: lib.genAttrs (import inputs.systems) (system: f system pkgsFor.${system});
in
{
packages = eachSystem (
system: pkgs: {
default = pkgs.callPackage ./flake/package.nix { };
CHANGE_NAME = self.packages.${system}.default;
}
);
devShells = eachSystem (
_system: pkgs: {
default = pkgs.callPackage ./flake/shell.nix { };
}
);
formatter = eachSystem (_: pkgs: pkgs.callPackage ./flake/formatter.nix { });
};
}

View file

@ -0,0 +1,22 @@
{
writeShellApplication,
fd,
statix,
nixfmt-rfc-style,
deadnix,
nim-2_0,
}:
writeShellApplication {
name = "linter";
runtimeInputs = [
fd
statix
nixfmt-rfc-style
deadnix
nim-2_0
];
text = ''
fd -e nix -X deadnix -e \; -X nixfmt {}
fd -e nix -x statix fix {}
'';
}

View file

@ -0,0 +1,7 @@
{ buildNimPackage }:
buildNimPackage (_finalAttrs: {
pname = "CHANGE_ME";
version = "CHANGE_VER";
src = ../.;
})

View file

@ -0,0 +1,14 @@
{
mkShell,
nim-2_0,
nimble,
nimlsp,
}:
mkShell {
name = "nim";
packages = [
nim-2_0
nimble
nimlsp
];
}

View file

@ -0,0 +1,7 @@
# This is just an example to get you started. A typical hybrid package
# uses this file as the main entry point of the application.
import CHANGE_NAME/submodule
when isMainModule:
echo(getWelcomeMessage())

View file

@ -0,0 +1,6 @@
# This is just an example to get you started. Users of your hybrid library will
# import this file by writing ``import nimpkg/submodule``. Feel free to rename or
# remove this file altogether. You may create additional modules alongside
# this file as required.
proc getWelcomeMessage*(): string = "Hello, World!"

View file

@ -0,0 +1 @@
switch("path", "$projectDir/../src")

View file

@ -0,0 +1,12 @@
# This is just an example to get you started. You may wish to put all of your
# tests into a single file, or separate them into multiple `test1`, `test2`
# etc. files (better names are recommended, just make sure the name starts with
# the letter 't').
#
# To run these tests, simply execute `nimble test`.
import unittest
import CHANGE_NAME/submodule
test "correct welcome":
check getWelcomeMessage() == "Hello, World!"

1
templates/rust/.envrc Normal file
View file

@ -0,0 +1 @@
use flake .#

View file

@ -3,5 +3,5 @@
version = 3
[[package]]
name = "rust-app"
version = "0.1.0"
name = "CHANGE_NAME"
version = "CHANGE_VER"

View file

@ -1,6 +1,6 @@
[package]
name = "rust-app"
version = "0.1.0"
name = "CHANGE_NAME"
version = "CHANGE_VER"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1733212471,
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
"lastModified": 1742889210,
"narHash": "sha256-hw63HnwnqU3ZQfsMclLhMvOezpM7RSB0dMAtD5/sOiw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
"rev": "698214a32beb4f4c8e3942372c694f40848b360d",
"type": "github"
},
"original": {
@ -16,43 +16,24 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust": "rust"
"systems": "systems"
}
},
"rust": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"systems": {
"locked": {
"lastModified": 1733279627,
"narHash": "sha256-NCNDAGPkdFdu+DLErbmNbavmVW9AwkgP7azROFFSB0U=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "4da5a80ef76039e80468c902f1e9f5c0eab87d96",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}

View file

@ -1,45 +1,25 @@
{
description = "Rust Developer Environment";
description = "CHANGE DESC";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust.url = "github:oxalica/rust-overlay";
systems.url = "github:nix-systems/default";
};
outputs = {
self,
nixpkgs,
rust,
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in {
packages = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust)
];
};
inherit system;
outputs = { self, nixpkgs, systems, }:
let
pkgsFor = nixpkgs.legacyPackages;
forAllSystems = f:
nixpkgs.lib.genAttrs (import systems)
(system: f system pkgsFor.${system});
in {
rust-app = pkgs.callPackage ./nix/package.nix {};
default = self.packages.${system}.rust-app;
});
packages = forAllSystems (system: pkgs: {
default = pkgs.callPackage ./nix/package.nix { };
CHANGE_NAME = self.packages.${system}.default;
});
devShells = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust)
];
};
inherit system;
in {
default = pkgs.callPackage ./nix/shell.nix {
inherit (self.packages.${system}) rust-app;
};
});
};
devShells = forAllSystems
(_: pkgs: { default = pkgs.callPackage ./nix/shell.nix { }; });
formatter =
forAllSystems (_: pkgs: pkgs.callPackage ./nix/formatter.nix { });
};
}

View file

@ -0,0 +1,10 @@
{ writeShellApplication, fd, nixfmt, deadnix, statix, rustfmt }:
writeShellApplication {
name = "liner";
runtimeInputs = [ fd nixfmt deadnix statix rustfmt ];
text = ''
fd -e nix -X nixfmt {} \; -X deadnix -e {} \;
fd -e nix -x statix fix {} \;
fd -e rs -X rustfmt {} \;
'';
}

View file

@ -1,6 +1,7 @@
{ rustPlatform }: let
pname = "rust-app";
version = "0.1.0";
{ rustPlatform }:
let
pname = "CHANGE_NAME";
version = "CHANGE_VER";
in rustPlatform.buildRustPackage {
inherit pname version;
src = ../.;

View file

@ -1,8 +1,5 @@
{ mkShell, rust-app, rust-bin }:
{ mkShell, rustc, cargo, nixfmt, deadnix, statix, rustfmt, clippy }:
mkShell {
name = "Rust Rivers";
inputsFrom = [ rust-app ];
buildInputs = [
rust-bin.stable.latest.default
];
name = "rust";
packages = [ nixfmt deadnix statix rustfmt clippy rustc cargo ];
}