From 0825f048cdc74371b08dbbdb80e5b575c00b03a5 Mon Sep 17 00:00:00 2001 From: Julian Mutter Date: Wed, 18 Dec 2024 00:35:16 +0100 Subject: [PATCH] Add nix flake for reproducible development environment --- .envrc | 1 + .gitignore | 1 + .metadata | 29 +++++++------------------- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 44 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 22 deletions(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix 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/.gitignore b/.gitignore index 24476c5..9eb3457 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release +/.direnv/ diff --git a/.metadata b/.metadata index 3a093f3..50331c0 100644 --- a/.metadata +++ b/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - channel: stable + revision: "nixpkgs000000000000000000000000000000000" + channel: "stable" project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - base_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - - platform: android - create_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - base_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - - platform: ios - create_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - base_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - - platform: linux - create_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - base_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - - platform: macos - create_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - base_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a + create_revision: nixpkgs000000000000000000000000000000000 + base_revision: nixpkgs000000000000000000000000000000000 - platform: web - create_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - base_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - - platform: windows - create_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a - base_revision: b4bce91dd0f168179d46a7ae5eceb3572ba9637a + create_revision: nixpkgs000000000000000000000000000000000 + base_revision: nixpkgs000000000000000000000000000000000 # User provided section diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..18d0c54 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1734466380, + "narHash": "sha256-BERwUGx7BMin5JqBYWjjD/QLZpREQBloR2CpPBc6opY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ec91155148c857617fbf98ec1eabc61485181b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs-unstable": "nixpkgs-unstable" + } + }, + "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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b36347d --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "Flutter"; + inputs = { + nixpkgs-unstable.url = "github:NixOS/nixpkgs/master"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = + { + self, + nixpkgs-unstable, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs-unstable { + inherit system; + config = { + android_sdk.accept_license = true; + allowUnfree = true; + }; + }; + buildToolsVersion = "33.0.2"; + androidComposition = pkgs.androidenv.composeAndroidPackages { + buildToolsVersions = [ buildToolsVersion ]; + platformVersions = [ "33" ]; + abiVersions = [ "arm64-v8a" ]; + }; + androidSdk = androidComposition.androidsdk; + in + { + devShell = + with pkgs; + mkShell rec { + ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk"; + buildInputs = [ + flutter + androidSdk + jdk11 + ]; + }; + } + ); +}