From 88f38822a607386d4ff75c5e5da3812e6326676b Mon Sep 17 00:00:00 2001 From: surtur Date: Tue, 26 Apr 2022 15:08:36 +0200 Subject: [PATCH] flake: add flake-compat+default.nix+shell.nix --- README.md | 7 +++++++ default.nix | 14 ++++++++++++++ flake.lock | 17 +++++++++++++++++ flake.nix | 7 ++++++- shell.nix | 14 ++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 default.nix create mode 100644 shell.nix diff --git a/README.md b/README.md index e39a82d..aab9d3d 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,13 @@ that means you can get started: run `nix develop` in the project folder *first*, then `go {run,build,fmt,...}` about your day. +### developing using nix (without flakes) +> for compatibility with non-flake-enabled systems, this project uses +> [`github:edolstra/flake-compat`](https://github.com/edolstra/flake-compat). + +run `nix-shell` in the project folder *first*, then `go {run,build,fmt,...}` +about your day. + ### developing without nix > *note*: you only need to have the Go toolchain and [Fyne > dependencies](https://developer.fyne.io/started/#prerequisites) installed for diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..cb27f93 --- /dev/null +++ b/default.nix @@ -0,0 +1,14 @@ +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + } +).defaultNix diff --git a/flake.lock b/flake.lock index 2362728..f73ac1a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1650161686, @@ -17,6 +33,7 @@ }, "root": { "inputs": { + "flake-compat": "flake-compat", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 5f78e7c..dbfbfea 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,15 @@ { description = "an offline-capable xkcd webcomic reader written in Go"; + inputs.flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + inputs.nixpkgs.follows = "nixpkgs"; + }; # Nixpkgs / NixOS version to use. inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, ... }: let # to work with older version of flakes diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..ed7286c --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + } +).shellNix