From 6be1c9d65c34b7dd31500e3fd2b3eaca8429e18c Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 29 Jul 2025 21:54:35 +0100 Subject: [PATCH] Add Nix flake --- .envrc | 1 + Dockerfile | 8 --- docker-compose.yaml | 6 --- flake-modules/dev-shell.nix | 18 +++++++ flake-modules/systems.nix | 3 ++ flake.lock | 98 +++++++++++++++++++++++++++++++++++++ flake.nix | 15 ++++++ run | 11 ----- 8 files changed, 135 insertions(+), 25 deletions(-) create mode 100644 .envrc delete mode 100644 Dockerfile delete mode 100644 docker-compose.yaml create mode 100644 flake-modules/dev-shell.nix create mode 100644 flake-modules/systems.nix create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100755 run diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f910332..0000000 --- a/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM golang:alpine - -WORKDIR /app - -RUN adduser --disabled-password golang \ - && chown golang:golang -R /app - -USER golang diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 230a47d..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,6 +0,0 @@ -services: - app: - build: "." - volumes: - - "./:/app" - working_dir: /app diff --git a/flake-modules/dev-shell.nix b/flake-modules/dev-shell.nix new file mode 100644 index 0000000..fb61d3d --- /dev/null +++ b/flake-modules/dev-shell.nix @@ -0,0 +1,18 @@ +{ inputs, ... }: + +{ + imports = [ + inputs.devshell.flakeModule + ]; + + perSystem = + { pkgs, ... }: + { + devshells.default = { + packages = with pkgs; [ + go + gopls + ]; + }; + }; +} diff --git a/flake-modules/systems.nix b/flake-modules/systems.nix new file mode 100644 index 0000000..ce708c6 --- /dev/null +++ b/flake-modules/systems.nix @@ -0,0 +1,3 @@ +{ + systems = [ "x86_64-linux" ]; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d9770f5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,98 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741473158, + "narHash": "sha256-kWNaq6wQUbUMlPgw8Y+9/9wP0F8SHkjy24/mN3UAppg=", + "owner": "numtide", + "repo": "devshell", + "rev": "7c9e793ebe66bcba8292989a68c0419b737a22a0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1753121425, + "narHash": "sha256-TVcTNvOeWWk1DXljFxVRp+E0tzG1LhrVjOGGoMHuXio=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "644e0fc48951a860279da645ba77fe4a6e814c5e", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "import-tree": { + "locked": { + "lastModified": 1752730890, + "narHash": "sha256-GES8fapSLGz36MMPRVNkSUWXUTtqvGQNXHjRmRLfJUY=", + "owner": "vic", + "repo": "import-tree", + "rev": "6ebb8cb87987b20264c09296166543fd3761d274", + "type": "github" + }, + "original": { + "owner": "vic", + "repo": "import-tree", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1753694789, + "narHash": "sha256-cKgvtz6fKuK1Xr5LQW/zOUiAC0oSQoA9nOISB0pJZqM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dc9637876d0dcc8c9e5e22986b857632effeb727", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1751159883, + "narHash": "sha256-urW/Ylk9FIfvXfliA1ywh75yszAbiTEVgpPeinFyVZo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "14a40a1d7fb9afa4739275ac642ed7301a9ba1ab", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-parts": "flake-parts", + "import-tree": "import-tree", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..08e0127 --- /dev/null +++ b/flake.nix @@ -0,0 +1,15 @@ +{ + inputs = { + devshell.inputs.nixpkgs.follows = "nixpkgs"; + devshell.url = "github:numtide/devshell"; + flake-parts.url = "github:hercules-ci/flake-parts"; + import-tree.url = "github:vic/import-tree"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ (inputs.import-tree ./flake-modules) ]; + }; +} diff --git a/run b/run deleted file mode 100755 index 21f223a..0000000 --- a/run +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -function ci:test { - go test "${@}" -} - -function go { - docker-compose run --rm app go "${@}" -} - -eval "$@"