summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParthiv Seetharaman <pachum99@myrdd.info>2022-02-02 12:37:54 -0800
committerParthiv Seetharaman <pachum99@myrdd.info>2022-02-02 12:40:17 -0800
commit47d65f14fc245e41a373c9500a7437dff12b4ed6 (patch)
tree74746e8e8f0029084408d760c70db79dbf12b309
parent6c50a62830d41428dafd8ffc73de398ab41c08a8 (diff)
re-organize repo to pass system and inputs around
follows super stupid flakes contract in the unofficial flakes roadmap
-rw-r--r--default.nix15
-rw-r--r--flake.lock47
-rw-r--r--flake.nix47
-rw-r--r--packages.nix6
-rw-r--r--pkgs/default.nix14
-rw-r--r--pkgs/mautrix-wsproxy/default.nix2
-rw-r--r--test.nix240
7 files changed, 194 insertions, 177 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..9d62c95
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,15 @@
+let
+ inherit (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;
+in
+ # Pass this flake as inputs.self
+ defaultNix // { inputs = defaultNix.inputs // { self = defaultNix; }; }
+
diff --git a/flake.lock b/flake.lock
index d3d2487..5afbe38 100644
--- a/flake.lock
+++ b/flake.lock
@@ -15,59 +15,56 @@
"type": "github"
}
},
- "flake-utils": {
+ "flake-compat": {
+ "flake": false,
"locked": {
- "lastModified": 1638122382,
- "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
+ "lastModified": 1641205782,
+ "narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
- "owner": "numtide",
- "repo": "flake-utils",
+ "owner": "edolstra",
+ "repo": "flake-compat",
"type": "github"
}
},
- "fup": {
- "inputs": {
- "flake-utils": "flake-utils"
- },
+ "nixlib": {
"locked": {
- "lastModified": 1638994888,
- "narHash": "sha256-iz/ynGNZlvqKCOnFrEKqGA+BVKGQMG+g2JT+e3OOLN8=",
+ "lastModified": 1643502816,
+ "narHash": "sha256-Wrbt6Gs+hjXD3HUICPBJHKnHEUqiyx8rzHCgvqC1Bok=",
"owner": "divnix",
- "repo": "flake-utils-plus",
- "rev": "b4f9f517574cb7bd6ee3f19c72c19634c9f536e1",
+ "repo": "nixpkgs.lib",
+ "rev": "ebed7ec5bcb5d01e298535989c6c321df18b631a",
"type": "github"
},
"original": {
"owner": "divnix",
- "repo": "flake-utils-plus",
+ "repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs": {
"locked": {
- "lastModified": 1642388384,
- "narHash": "sha256-ooGGteIJHxB0wIC6Hnn2Yn+rPPQR5yxO8GNu74OZoO0=",
+ "lastModified": 1643472818,
+ "narHash": "sha256-qzVPxKDUubYIxKRSuDl/JgzXWSmGvUVYny9SxFMfPJM=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "fc618794a5faac44e203b3a66002bd8d883019c4",
+ "rev": "7f65e4abd5ecaad12d2d26e4380d1a7d8edafea7",
"type": "github"
},
"original": {
- "owner": "NixOS",
- "ref": "release-21.11",
- "repo": "nixpkgs",
- "type": "github"
+ "id": "nixpkgs",
+ "type": "indirect"
}
},
"root": {
"inputs": {
"devshell": "devshell",
- "fup": "fup",
+ "flake-compat": "flake-compat",
+ "nixlib": "nixlib",
"nixpkgs": "nixpkgs"
}
}
diff --git a/flake.nix b/flake.nix
index b7319cf..f763fbf 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,40 +1,37 @@
{
inputs = {
- fup.url = "github:divnix/flake-utils-plus";
devshell.url = "github:numtide/devshell";
- nixpkgs.url = "github:NixOS/nixpkgs/release-21.11";
+ nixlib.url = "github:divnix/nixpkgs.lib";
+ flake-compat = {
+ url = "github:edolstra/flake-compat";
+ flake = false;
+ };
};
- outputs = inputs@{ self, nixpkgs, fup, devshell }:
- fup.lib.mkFlake {
- inherit self inputs;
+ outputs = inputs@{ self, nixlib, nixpkgs, devshell, ... }:
+ let
+
+ # Unofficial Flakes Roadmap - Polyfills
+ # This project is committed to the Unofficial Flakes Roadmap!
+ # .. see: https://demo.hedgedoc.org/s/_W6Ve03GK#
+ # Super Stupid Flakes (ssf) / System As an Input - Style:
supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
+ polyfillOutput = loc: nixlib.lib.genAttrs supportedSystems (system:
+ import loc { inherit system inputs; }
+ );
+ in
+ {
+
nixosModules.matrix-appservices = import ./module;
nixosModule = self.nixosModules.matrix-appservices;
- overlays.matrix-appservices = import ./pkgs;
+ overlays.matrix-appservices = final: prev: import ./pkgs { pkgs = prev; };
overlay = self.overlays.matrix-appservices;
- sharedOverlays = [
- self.overlay
- devshell.overlay
- ];
-
- channels.pkgs.input = nixpkgs;
-
- outputsBuilder = { pkgs }: {
- packages = {
- inherit (pkgs)
- mx-puppet-groupme
- mx-puppet-slack
-
- mautrix-twitter
- mautrix-instagram
- ;
- };
- checks.matrix-appservices = import ./test.nix { inherit pkgs; };
- };
+ packages = polyfillOutput ./packages.nix;
+
+ checks = polyfillOutput ./test.nix;
};
}
diff --git a/packages.nix b/packages.nix
new file mode 100644
index 0000000..52626fb
--- /dev/null
+++ b/packages.nix
@@ -0,0 +1,6 @@
+{ system ? builtins.currentSystem
+, inputs ? (import ./.).inputs
+}:
+import ./pkgs {
+ pkgs = inputs.nixpkgs.legacyPackages.${system};
+}
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 7589f50..7562c58 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -1,10 +1,8 @@
-final: prev: {
- mx-puppet-groupme = prev.callPackage ./mx-puppet-groupme { };
- mx-puppet-slack = prev.callPackage ./mx-puppet-slack { };
+{ pkgs }: {
+ mx-puppet-groupme = pkgs.callPackage ./mx-puppet-groupme { };
+ mx-puppet-slack = pkgs.callPackage ./mx-puppet-slack { };
- mautrix-twitter = prev.callPackage ./mautrix-twitter { };
- mautrix-instagram = prev.callPackage ./mautrix-instagram { };
- mautrix-wsproxy = prev.callPackage ./mautrix-wsproxy { };
-
- matrix-emailbridge = prev.callPackage ./matrix-emailbridge { };
+ mautrix-twitter = pkgs.callPackage ./mautrix-twitter { };
+ mautrix-instagram = pkgs.callPackage ./mautrix-instagram { };
+ mautrix-wsproxy = pkgs.callPackage ./mautrix-wsproxy { };
}
diff --git a/pkgs/mautrix-wsproxy/default.nix b/pkgs/mautrix-wsproxy/default.nix
index fb5d7d9..1fd3d9f 100644
--- a/pkgs/mautrix-wsproxy/default.nix
+++ b/pkgs/mautrix-wsproxy/default.nix
@@ -17,7 +17,7 @@ buildGoModule rec {
doCheck = false;
- runVend = true;
+ proxyVendor = true;
postInstall = ''
mv $out/bin/mautrix-wsproxy $out/bin/mautrix-wsproxy-bin
diff --git a/test.nix b/test.nix
index 0257623..fd6e3f0 100644
--- a/test.nix
+++ b/test.nix
@@ -1,123 +1,127 @@
-{ pkgs ? import <nixpkgs> { } }:
-(import "${pkgs.path}/nixos/tests/make-test-python.nix" (
- { pkgs, ... }:
- let
- homeserverURL = "http://homeserver:8008";
- homeserverDomain = "example.com";
-
- private_key = pkgs.runCommand "matrix_key.pem" {
- buildInputs = [ pkgs.dendrite ];
- } "generate-keys --private-key $out";
- in
- {
- name = "dendrite";
- meta = with pkgs.lib; {
- maintainers = teams.matrix.members;
- };
-
- nodes = {
- homeserver = { pkgs, ... }: {
- imports = [ ./module ];
- services.dendrite = {
- enable = true;
- settings = {
- global.server_name = homeserverDomain;
- global.private_key = private_key;
- client_api.registration_disabled = false;
- };
+{ system ? builtins.currentSystem
+, inputs ? (import ./.).inputs
+}:
+let
+ pkgs = inputs.nixpkgs.legacyPackages.${system};
+
+ homeserverURL = "http://homeserver:8008";
+ homeserverDomain = "example.com";
+
+ private_key = pkgs.runCommand "matrix_key.pem" {
+ buildInputs = [ pkgs.dendrite ];
+ } "generate-keys --private-key $out";
+in
+ {
+ matrix-appservices = pkgs.nixosTest {
+ name = "matrix-appservices";
+ meta = with pkgs.lib; {
+ maintainers = teams.matrix.members;
+ };
+
+ nodes = {
+ homeserver = { pkgs, ... }: {
+ imports = [ ./module ];
+ services.dendrite = {
+ enable = true;
+ settings = {
+ global.server_name = homeserverDomain;
+ global.private_key = private_key;
+ client_api.registration_disabled = false;
};
-
- networking.firewall.allowedTCPPorts = [ 8008 ];
-
- services.matrix-appservices = {
- inherit homeserverDomain homeserverURL;
- addRegistrationFiles = true;
- homeserver = "dendrite";
- services = {
- discord = {
- port = 29180;
- package = pkgs.mx-puppet-discord;
- format = "mx-puppet";
- };
+ };
+
+ networking.firewall.allowedTCPPorts = [ 8008 ];
+
+ services.matrix-appservices = {
+ inherit homeserverDomain homeserverURL;
+ addRegistrationFiles = true;
+ homeserver = "dendrite";
+ services = {
+ discord = {
+ port = 29180;
+ package = pkgs.mx-puppet-discord;
+ format = "mx-puppet";
};
};
};
-
- client = { pkgs, ... }: {
- environment.systemPackages = [
- (
- pkgs.writers.writePython3Bin "do_test"
- { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
- import asyncio
-
- from nio import AsyncClient
-
-
- async def main() -> None:
- # Connect to dendrite
- client = AsyncClient("http://homeserver:8008", "alice")
-
- # Register as user alice
- response = await client.register("alice", "my-secret-password")
-
- # Log in as user alice
- response = await client.login("my-secret-password")
-
- # Create a new room
- response = await client.room_create(federate=False)
- room_id = response.room_id
-
- # Join the room
- response = await client.join(room_id)
-
- # Invite whatsapp user to room
- response = await client.room_invite(
- room_id,
- "@_discordpuppet_bot:${homeserverDomain}"
- )
-
- # Send a message to the room
- response = await client.room_send(
- room_id=room_id,
- message_type="m.room.message",
- content={
- "msgtype": "m.text",
- "body": "ping"
- }
- )
-
- # Sync responses
- response = await client.sync(timeout=30000)
-
- response = await client.joined_members(room_id)
-
- # Check the message was received by dendrite
- # last_message = response.rooms.join[room_id].timeline.events[-1].body
-
- # Leave the room
- response = await client.room_leave(room_id)
-
- # Close the client
- await client.close()
-
- asyncio.get_event_loop().run_until_complete(main())
- ''
- )
- ];
- };
};
-
- testScript = ''
- start_all()
-
- with subtest("start the homeserver"):
- homeserver.wait_for_unit("dendrite.service")
- homeserver.wait_for_open_port(8008)
- homeserver.wait_for_unit("matrix-as-discord.service")
-
- with subtest("ensure messages can be exchanged"):
- client.succeed("do_test")
- '';
-
- }
-)) { inherit (pkgs) pkgs system; }
+
+ client = { pkgs, ... }: {
+ environment.systemPackages = [
+ (
+ pkgs.writers.writePython3Bin "do_test"
+ { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
+ import asyncio
+
+ from nio import AsyncClient
+
+
+ async def main() -> None:
+ # Connect to dendrite
+ client = AsyncClient("http://homeserver:8008", "alice")
+
+ # Register as user alice
+ response = await client.register("alice", "my-secret-password")
+
+ # Log in as user alice
+ response = await client.login("my-secret-password")
+
+ # Create a new room
+ response = await client.room_create(federate=False)
+ room_id = response.room_id
+
+ # Join the room
+ response = await client.join(room_id)
+
+ # Invite whatsapp user to room
+ response = await client.room_invite(
+ room_id,
+ "@_discordpuppet_bot:${homeserverDomain}"
+ )
+
+ # Send a message to the room
+ response = await client.room_send(
+ room_id=room_id,
+ message_type="m.room.message",
+ content={
+ "msgtype": "m.text",
+ "body": "ping"
+ }
+ )
+
+ # Sync responses
+ response = await client.sync(timeout=30000)
+
+ response = await client.joined_members(room_id)
+
+ # Check the message was received by dendrite
+ # last_message = response.rooms.join[room_id].timeline.events[-1].body
+ # assert last_message = "ping"
+
+ # Leave the room
+ response = await client.room_leave(room_id)
+
+ # Close the client
+ await client.close()
+
+ asyncio.get_event_loop().run_until_complete(main())
+ ''
+ )
+ ];
+ };
+ };
+
+ testScript = ''
+ start_all()
+
+ with subtest("start the homeserver"):
+ homeserver.wait_for_unit("dendrite.service")
+ homeserver.wait_for_open_port(8008)
+ homeserver.wait_for_unit("matrix-as-discord.service")
+
+ with subtest("ensure messages can be exchanged"):
+ client.succeed("do_test")
+ '';
+
+ };
+ }