Add template scaffolding

This commit is contained in:
Daniel Lundin 2024-09-23 17:12:50 +02:00
commit 1f31615620
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
10 changed files with 205 additions and 0 deletions

2
.envrc.recommended Normal file
View file

@ -0,0 +1,2 @@
use flake
dotenv_if_exists

View file

@ -0,0 +1,5 @@
#${PullRequestIndex} ${PullRequestTitle}
${PullRequestDescription}
Reviewed-on: https://patagia.dev/${BaseRepoOwnerName}/${BaseRepoName}/pulls/${PullRequestIndex}

View file

@ -0,0 +1,5 @@
#${PullRequestIndex} ${PullRequestTitle}
${PullRequestDescription}
Reviewed-on: https://patagia.dev/${BaseRepoOwnerName}/${BaseRepoName}/pulls/${PullRequestIndex}

View file

@ -0,0 +1,5 @@
#${PullRequestIndex} ${PullRequestTitle}
${PullRequestDescription}
Reviewed-on: https://patagia.dev/${BaseRepoOwnerName}/${BaseRepoName}/pulls/${PullRequestIndex}

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.direnv
.env
.envrc
.git
result*

33
.woodpecker/ci.yaml Normal file
View file

@ -0,0 +1,33 @@
when:
- event: pull_request
- event: push
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
check:
image: alpine
volumes:
- nix:/nix
commands:
# install nix
- |
test -f /nix/installer || wget -O /nix/installer https://github.com/DeterminateSystems/nix-installer/releases/download/v0.18.0/nix-installer-x86_64-linux
chmod +x /nix/installer
rm -f /nix/receipt.json /nix/nix-installer
/nix/installer install linux --init=none --no-confirm
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
# configure nix
- |
mkdir -p /etc/nix
cat <<EOF > /etc/nix/nix.conf
sandbox = false
experimental-features = nix-command flakes
EOF
# build
- nix build .
# check
- nix flake check

1
README.md Normal file
View file

@ -0,0 +1 @@
# My Project

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1726969270,
"narHash": "sha256-8fnFlXBgM/uSvBlLWjZ0Z0sOdRBesyNdH0+esxqizGc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "23cbb250f3bf4f516a2d0bf03c51a30900848075",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"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
}

60
flake.nix Normal file
View file

@ -0,0 +1,60 @@
{
description = "My Project";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
};
outputs =
{
self,
flake-utils,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
# Formatter for the Nix code
formatter = pkgs.nixpkgs-fmt;
# Checks/tests for the project
checks = {
# FIXME: Add actual tests
simple-test = pkgs.runCommand "simple-test" { } ''
${self.packages.${system}.default}/bin/my-program
touch $out
'';
};
# Packages
packages = {
my-program = pkgs.writeShellScriptBin "my-program" ''
${pkgs.ddate}/bin/ddate +'Hello, world! Today is the %e of %B%, %Y' |
${pkgs.cowsay}/bin/cowsay
'';
default = self.packages.${system}.my-program;
};
# Development shell
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
just
watchexec
];
shellHook = ''
echo
echo " Welcome to the My Project development environment! "
echo "Run 'just' to see available commands."
echo
'';
};
}
);
}

28
justfile Normal file
View file

@ -0,0 +1,28 @@
set shell := ["/usr/bin/env", "bash", "-euo", "pipefail", "-c"]
[private]
default:
@just --choose
# Run all tests
test:
nix flake check
# Lint all source code
lint:
echo FIXME: Add linter(s) here
# Format all source code
fmt:
echo FIXME: Add formatter here
# Update all dependencies
update: update-nix-pkgs
# Update nix flake packages
update-nix-pkgs:
nix flake update
# Run local development
dev $OTEL_SERVICE_NAME="my-project":
watchexec --clear --restart --stop-signal INT --debounce 300ms -- nix run .