From 3dc9935de41ab5e122c3ce521a0a979df3ef2d9d Mon Sep 17 00:00:00 2001 From: Kristian Krsnik Date: Sun, 28 Jan 2024 18:36:58 +0100 Subject: [PATCH] initial commit --- .envrc | 1 + .gitignore | 4 +++ README.md | 27 +++++++++++++++++++ flake.lock | 27 +++++++++++++++++++ flake.nix | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 README.md 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 new file mode 100644 index 0000000..706a090 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +result + +.direnv/ +*.AppImage diff --git a/README.md b/README.md new file mode 100644 index 0000000..08fda2c --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Story Architect Flake + +This flake packages the [Moosync](https://github.com/Moosync/Moosync) AppImage. + +## Build + +```txt +nix build +``` + +## Developing + +```txt +nix develop +``` + +This will put you in a shell with `appimage-run` and other useful utilities. +It will also download the AppImage that is currently being packaged. +To manually download the AppImage do: + +```txt +nix run .#dev +``` + +### Resources + +* [Nix Manual](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-appimageTools) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0716ea3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1705856552, + "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..62493d3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,79 @@ +{ + description = "Moosync is a customizable desktop music player with a clean interface."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { + self, + nixpkgs, + }: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + + name = "moosync"; + version = "10.3.0"; + + src = pkgs.fetchurl { + url = "https://github.com/Moosync/Moosync/releases/download/v${version}/Moosync-${version}-linux-x86_64.AppImage"; + sha256 = "sha256-Mr8dTpjHs+1S3kOKZ2VGBQuY8z/8+sCNEIyp9FTc7iw="; + }; + + desktopItem = pkgs.makeDesktopItem { + inherit name; + exec = name; + desktopName = "Moosync"; + terminal = false; + icon = name; + startupWMClass = "Moosync"; + comment = "Moosync is a customizable desktop music player with a clean interface"; + mimeTypes = ["x-scheme-handler/moosync"]; + categories = ["Audio"]; + extraConfig = {X-AppImage-Version = version;}; + }; + in { + packages.${system} = { + default = pkgs.appimageTools.wrapType2 { + inherit name src; + + extraInstallCommands = let + contents = pkgs.appimageTools.extract { + inherit name src; + }; + in '' + # Install .desktop file + install -m 444 ${desktopItem}/share/applications/${name}.desktop -Dt $out/share/applications + + # Install icons + for file in $(find ${contents}/usr/share/icons -type f); do + directory=$(dirname ''${file#${contents}/usr}) + install -m 444 $file -D $out/$directory/${name}.png + done + ''; + }; + }; + + apps.${system} = { + dev = { + program = "${pkgs.writeShellScript "download-appimage" '' + ${pkgs.curl}/bin/curl ${src.url} -C - -Lo ${name}.AppImage + ''}"; + type = "app"; + }; + }; + + devShells.${system} = { + default = pkgs.mkShellNoCC { + packages = with pkgs; [ + appimage-run + file + ]; + + shellHook = '' + ${self.apps.${system}.dev.program} + ''; + }; + }; + }; +}