From 9d455ba753806fb3c42835dd5632306ad81ddbbd Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:49:32 +0200 Subject: [PATCH] feat: flake-compat --- .license-tools-config.json | 2 ++ README.md | 61 ++++++++++++++++++++++++++------------ default.nix | 16 ++++++++++ flake.lock | 15 ++++++++++ flake.nix | 7 +++++ 5 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 default.nix diff --git a/.license-tools-config.json b/.license-tools-config.json index c361afa..a7c368a 100644 --- a/.license-tools-config.json +++ b/.license-tools-config.json @@ -7,10 +7,12 @@ "style_override_for_suffix": { ".yaml": "POUND_STYLE", ".ps1": "POUND_STYLE", + ".nix": "POUND_STYLE", ".bat": "BATCH_STYLE", "": "POUND_STYLE" }, "exclude": [ + "flake.lock", "^\\.[^/]+", "/\\.[^/]+", "^(.+)\\.(md|svg|png|reg|gif)", diff --git a/README.md b/README.md index bc2a160..6783278 100644 --- a/README.md +++ b/README.md @@ -487,6 +487,7 @@ nix profile install github:winapps-org/winapps#winapps-launcher # optional ### On NixOS using Flakes ```nix +# flake.nix { description = "My configuration"; @@ -494,38 +495,60 @@ nix profile install github:winapps-org/winapps#winapps-launcher # optional nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; winapps = { - url = ""github:winapps-org/winapps; + url = "" "github:winapps-org/winapps"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { - nixpkgs, - winapps, - ... - }: { - nixosConfigurations.hostname = nixpkgs.lib.nixosSystem rec { - system = "x86_64-linux"; + outputs = + { + nixpkgs, + winapps, + ... + }: + { + nixosConfigurations.hostname = nixpkgs.lib.nixosSystem rec { + system = "x86_64-linux"; - modules = [ - ./configuration.nix - ({pkgs, ...}: { - environment.systemPackages = [ - winapps.packages.${system}.winapps - winapps.packages.${system}.winapps-launcher # optional - ]; - }) - ]; + modules = [ + ./configuration.nix + ( + { pkgs, ... }: + { + environment.systemPackages = [ + winapps.packages.${system}.winapps + winapps.packages.${system}.winapps-launcher # optional + ]; + } + ) + ]; + }; }; - }; } ``` ### On NixOS without Flakes [Flakes aren't real and they can't hurt you.](https://jade.fyi/blog/flakes-arent-real/). -See https://wiki.nixos.org/wiki/Flakes#Using_nix_flakes_with_NixOS on how to enable Flakes on your system. +However, if you still don't want to use flakes, you can use WinApps with flake-compat like: +```nix +# configuration.nix +{ ... }: +{ + + environment.systemPackages = + let + winapps = + (import (builtins.fetchTarball "https://github.com/winapps-org/winapps/archive/main.tar.gz")) + .packages."${system}"; + in + [ + winapps.winapps + winapps.winapps-launcher # optional + ]; +} +``` ## Star History diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..0cd5241 --- /dev/null +++ b/default.nix @@ -0,0 +1,16 @@ +# Copyright (c) 2024 Oskar Manhart +# All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = + lock.nodes.flake-compat.locked.url + or "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 b07995a..dc621f0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,19 @@ { "nodes": { + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -36,6 +50,7 @@ }, "root": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 5bf6d8f..22c8b5c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,15 @@ +# Copyright (c) 2024 Oskar Manhart +# All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0-or-later + { description = "WinApps Nix packages & NixOS module"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; flake-utils.url = "github:numtide/flake-utils"; };